Note that there are some explanatory texts on larger screens.

plurals
  1. POA jscript variable in a Query
    primarykey
    data
    text
    <p>Maybe a very simple question.</p> <p>How can I put in this code</p> <pre><code>&lt;Query&gt; &lt;Where&gt; &lt;Eq&gt; &lt;FieldRef Name="Judge_x0020_1" /&gt; &lt;Value Type="Text"&gt;mr. R. Sanches&lt;/Value&gt; &lt;/Eq&gt; &lt;/Where&gt; &lt;/Query&gt; </code></pre> <p>A variable from jscript in the area of the code where mr. R. Sanches is written. So my jScript contains a dynamic text variable I want to replace mr. R. Sanches with. See where it says THE JAVESCRIPT VAR underneath here:</p> <p>jScript code I have</p> <pre><code>&lt;script src="/JavascriptMODS/jPointLoader.js"&gt;&lt;/script&gt; &lt;script src="/JavascriptMODS/jPoint.userprofile.js"&gt;&lt;/script&gt; &lt;SCRIPT type=text/javascript&gt; // Picks the userfield it is going to search with var user = jP.getUserProfile(); var userinfspvalue = user.Department; // removes the non breaking space at the end of the departmentfieldcontent var removenonbreakingspace = String.fromCharCode(160); userinfspvalue = userinfspvalue.replace(removenonbreakingspace,''); &lt;/script&gt; </code></pre> <p>Userinfspvalue is the var I would like to use.</p> <p>In the CAML query</p> <pre><code>&lt;Query&gt; &lt;Where&gt; &lt;Eq&gt; &lt;FieldRef Name="Judge_x0020_1" /&gt; &lt;Value Type="Text"&gt;Userinfspvalue&lt;/Value&gt; &lt;/Eq&gt; &lt;/Where&gt; &lt;/Query&gt; </code></pre> <p>What is jP.getUserProfile()?</p> <p>Code (i didnt create it).</p> <pre><code>/* * name: jPoint.userprofile.js * purpose: get user profile info from /_layouts/userdisp.aspx * input: none * visibility: public * return: jP.UserProfile (object) * jP.UserProfile.Name * jP.UserProfile.Account * jP.UserProfile.Title * jP.UserProfile.EMail * jP.UserProfile.Notes * jP.UserProfile.AboutMe * jP.UserProfile.Picture * jP.UserProfile.Department * jP.UserProfile.JobTitle * jP.UserProfile.SipAddress * jP.UserProfile.SIPAddress * * jP.UserProfile.FieldCount //count of fields * jP.UserProfile.Fields //array of field names * jP.UserProfile.Items[0].Name ... SipAddress * * use example: * var usrprof = jP.getUserProfile(userID); //userID is optional * var name = usrprof.Name; * var email = usrprof.EMail; * var dept = usrprof.Department; */ (function(jP) { jP.getUserProfile = function (UserID) { var ProfileURL = jP.SiteURL+"/_layouts/userdisp.aspx"; if(typeof UserID !== "undefined") ProfileURL = ProfileURL + "?ID=" + UserID; $.ajax( { type: "GET", //jQuery ajax GET async: false, cache: false, url: ProfileURL, //userprofile url success: function(data){ var tags = $(data).find("h3 &gt; a"); //look for anchor in h3 tag if (tags.length &gt; 0) { var profile = {}; var fields = []; var item = {}; $.each(tags, function(){ var name = this.name; //name attritbute var td = $(data).find("tr a[name='"+name+"']").parent().parent(); //get label td var labelname = jP.strip(td.text()); //get label text as field name if (labelname == "Picture") { //special handling for Picture field //concat attribute alt and src together var img = td.siblings().find("img"); var val = img.attr("alt") + ";#" + img.attr("src"); } else { //get text of next td cell var val = $.trim(td.siblings().text()); } var intname = name.substr(name.indexOf("_")+1); //internal field name if ($.inArray(intname, fields)==-1) { //save as internal fieldname fields.push(intname); item[intname] = profile[intname] = val; } if ($.inArray(labelname, fields)==-1) { //save as label fieldname fields.push(labelname); item[labelname] = profile[labelname] = val; } }); //Set profile obj profile["Fields"] = fields; profile["FieldCount"] = fields.length; profile["Items"] = [item]; //set UserProfile obj jP["UserProfile"] = profile; } } }); return (jP["UserProfile"]) } })(jPoint); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload