I am wondering if anyone could clarify my confusion on how to use JavaScript to read/filter SharePoint List items, please?
As a code example from MSDN:
https://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
In the CAML query XML, what is the FieldRef field in SharePoint List? Is it defined column names/list properties?
When ClientContext object load collListItem, it has a (Include) parameter which includes a bunch of field/property names, what are they? Are they defined column names/list properties as well?
Is there anyway I can know what field names are, so I can use/filter the List?
Thank you.
The FieldRef is the internal field name of the column. Sometimes it's the same as the display name but as the display name can be changed you can't be certain of this. When creating new columns, I find it best to create them WithoutSpacesLikeThis and then replace the spaces once created. This makes it much easier to see what's happening when you're referencing them in code or in a URL etc. The same with Sites,Lists, Libraries etc.
The quickest way to find the internal name is to open the column as if you were going to edit it and then look in the URL and you will find the internal name there.
For example, the internal name of ApprovalStatus is at the end of the below URL after Field=. If the field has been created with a space in the name the space will be replaced by %20. E.g. Approval%20Status.
_layouts/15/FldEdit.aspx?List=%7BE07BFB18-BBED-4A57-8988-6CAEB47FAA02%7D&Field=ApprovalStatus
Another way to see the field names would be to use the REST api. You can do this by adding _api/web/lits/getbytitle('NameOfList')/items to the end of the site collection URL. However, depending on the number of items you have in the list, it might return a lot of data.
https://tenant.sharepoint.com/sites/app/_api/web/lists/getbytitle('NameOfList)/items
When ClientContext object load collListItem, it has a (Include)
parameter which includes a bunch of field/property names, what are
they? Are they defined column names/list properties as well?
As far as this part of your question is concerned, can you provide some of the properties to give a better idea of what it is you're talking about, please?
Related
I have a simple SharePoint list which consists of 2 columns, username and a Boolean Yes/No expression. It is used for users to acknowledge that they have read a document. I would like to create a button that would set all users Boolean expression back to ‘No’ when the document is amended/updated. Is there a way to do this?
I am very new to SharePoint and have not had a lot of experience with JavaScript. Thanks in advance for any help!
SharePoint does not provide a way to confirm that the user whether has read the document.
As a workaround, you could add a workflow to update the list value ,Users can start the workflow after reading the document.
Can you please explain two columns that you have added are part of the same document library , Or document & two columns in separate list.
If you have idea of JavaScript, then you can write CSOM Javascript code to implement the above scenario. you can also make use of SharePoint REST Calls.
If you have idea of C#, then you can write even receivers to clear off the boolean values based on Document State Changes.
For SEO reasons I need to complete the Organization schema markup that is on a website but I only have access via javascript. I can't edit HTML, only JS and CSS overwrites. The Organization object is missing a telephone and other properties.
I rather not to create a second Organization object that is complete and have the good and the bad version up in the site. I was wondering if it is possible to reference an existing object somehow via json-ld? or do you think I should just add a second object?
I was wondering if it is possible to reference an existing object somehow via json-ld?
In practice, not really (theoretically you could give them the same identifier and when converted to RDF the data should be merged).
or do you think I should just add a second object?
I personally would do that. That way clients that (just) understand JSON-LD would get the complete information.
On our site, we have pages that can be assigned tags, and I'm having issues with figuring out how to handle this with Adobe DTM/Analytics. Each page can have between 1 and n tags being captured in an array. I can see them in the developer console just fine, ex:
> data.page.termIds
< [513, 1787, 115, 4330]
Each element corresponds to the tag ID.
I've been searching online but can't find any answers that really help me. This blog post is close, but it looks like they need to create a separate data element for each element in the array. I also found this question in the adobe forums, but it's similar to the blog post.
Does anyone know if this is even possible? Are we expected to create a block of data elements, with each one assigned to an array index?
Do not bother with the JS Object option unless you want to target a top level js object/variable. So for example foobar is okay but foo['bar'] or foo.bar is not. If you want to target anything "nested", skip JS Object and use Custom Script to check for it and return it, instead. This is because DTM doesn't do a good job of parsing or checking if the parent nodes exist before returning it. This is basically what was already said in the blog link you mentioned.
As for what the Data Element is returning and how to use it...the Data Element itself will have a return value of exactly what you return. So if you return an object, it will be an object. If you return an array, it will be an array. The trick (or caveat, or bug, depending on how you want to look at it) is how you reference or use the Data Element within the tools and rules.
The long story short of it is this: If you intend to use the %data_element_name% syntax (e.g. in any of the built in form fields in the rules, config settings, etc.) then you should only have your Data Element return a string type value (this is basically the issue the forum post link had, and I assume the issue you are running into).
If you want to be able to access it as some other type (e.g. the array, or js object in general), you need to use _satellite.getVar('data_element_name') syntax. The obvious drawback to this is it basically makes using DTM in a "non-coder" way useless in that you cannot use this in any of the built-in fields in rules. You can only use it in contexts where you can write javascript, e.g. Data > Custom type Conditions or in Javascript / 3rd Party Tag containers.
But one question for you is, what are you ultimately using the Data Element for? For example, if the end game here is you are looking to populate a prop or eVar or some other variable with a comma delimited string.. well just return your array as such in your Data Element and then you can use the %data_element_name% syntax.
Capturing the data is one thing and formatting is another.
My question is how do you need to see this data organized in reporting? Capturing the array itself doesn't do much unless you know what format you need it in. Are you hoping to capture these IDs and classify them? Do you want to see the array list by page?
Can you provide more detail on how you'll be reporting on these values?
In a form in CRM2011 I am using a JavaScript function to retrieve some attributes from a custom entity unrelated to the one in the form.
I have a successful call to CrmRestKit.RetrieveMultiple but I don't know what the returned collection comprises. Can someone point me in the right direction, please?
To be a little more specific about the requirement: the query returns a set of Field schema names; i.e. the column being queried is in a custom entity and contains schema names of Fields. I want to match each one I retrieve against the calling form's collection of Field-based controls so that I can perform an action on matching ones. Any assistance towards that would also be gratefully received, thanks.
The easiest way I have found to know what you'll be working with is to take the output and run it through JSON.stringify() and write the contents of that out to the page.
For bits like this I usually just debug with IE. That will allow you to add breakpoints and inspect the object.
Related info: Debugging Script with the Developer Tools.
I am working with NetSuite's server-side SuiteScript and need to access the display value of several custom Transaction Column Fields. The fields in question are each set up as type "List/Record" and are associated with existing Custom Lists.
Working in the NetSuite Script Debugger, I have inspected the values returned from nlapiLoadRecord('salesorder', orderInternalId). Looking at the Items in the resulting object (e.g. obj.sublists.item.line 1) I see that some of these List/Record custom fields provide both a number (the ID of the selected List entry) and a string (the displayed text value of the List entry), but other custom fields do not.
For example, I have two custom fields with IDs custcol1 and custcol2. These are both of type "List/Record". When the sales order is loaded, nlapiLoadRecord provides the fields "custcol1" (number) and "custcol1_display" (string) for custcol1, but only "custcol2" (number) for custcol2. I do not see any difference in the settings for these two custom fields, so it is unclear why one provides the string and the other does not.
I need to retrieve the string values for both fields. Is there a setting change I need to make so custcol2 will automatically return a "custcol2_display" value? Or is there another API call I can use to take the number value from "custcol2" and look up the associated string value in the underlying Custom List?
Try using record.getLineItemText('item', 'custcol2', linenum)
For debugging, I tend to use Firebug - it's a lot more effective than the NS debugger and quicker than logging statements for just testing things out.
I just noticed this is two years old, but I think you can put columnname.id to get the data value. It works for standard columns but not sure about custom ones.
One thing I have learned to use is the NetSuite debugger, I don't use it like a standard debugger but rather like the javascript console. Just paste in some code into the box and then debug it, it is great for seeing what the dang property values are and the data in them which seems to be a crapshoot in NetSuite.