I've the following in a SI
var serviceAsset=new GlideRecord('u_service_asset');
serviceAsset.addQuery('u_service',service_sys_id);
serviceAsset.addNotNullQuery('u_parent');
serviceAsset.query();
gs.log(serviceAsset.getEncodedQuery());
This prints the following in the logs
u_service=305baa6fdb17d0d44bb6e126059619e1^u_parent!=NULL^sys_idNotValidnull^ORsys_idNotValidnull
What does sys_idNotValidnull mean and why is it getting added as an OR condition?
I've a "Query" Business Rule on the table but that code doesn't seem to be referencing the above.
Business Rule code
(function executeRule(current, previous /*null when async*/) {
var serviceassetquery;
serviceassetquery = current.addEncodedQuery("u_sourcesystem!=Wholesale^ORu_sourcesystem=NULL");
})(current, previous);
So the
sys_idNotValidnull^ORsys_idNotValidnull
part was being added by the Business Rule. And the reason for sys_idNotValidnull presence was because the column u_sourcesystem was NOT present on the table u_service_asset
Duh! It was an invalid column after all that caused all the issue.
Assuming sys_idNotValidnull means "referred sys_id is not exist".
The easiest and best way to get an encoded query as follows:
Navigate to the table.
Build filter and run
Right-click on the bread crumb (You will see copy query option that will give proper encoded query, Please refer to the screenshot attached)
Example of copied query: "active=true^state!=10^ORstate=^sys_idISNOTEMPTY"
Related
I've been doing some work on Sharepoint Online/365 and have got stuck trying to set the value of a lookup or choice column in NewForm.aspx
Narrowed my problem down to not being able to set lookup/Choice Columns
I have simplified a code on my page down to
//Phase being a Choice Column & Closure a case sensitive valid option
$("select[title='Phase']").val("Closure");
//ProjectName being a Lookup Column & Test2 a case sensitive valid entry in the list
$("select[title='ProjectName']").val("Test2");
I have no problem setting text fields as the following code works fine on a text field I created
$("input[title='TextField']").val("Test2");
I have used the following Jquery libraries 1.7.2/min.js and 1.11.3
Not sure whether you used _spBodyOnLoadFunctionNames.push() method for your logics. Usually you have to wait all SharePoint DOM objects are loaded and then to execute your jQuery code. If you used SharePoint JavaScript library, you probably needs to call ExecuteOrDelayUntilScriptLoaded() to make sure your call is called after curtain SharePoint .js files are loaded.
First Thanks "Verona Chen" and " DIEGO CARRASCAL" because of who i've learnt a few other tricks in SharePoint which will help with other projects.
My original script before the question was trying to use a query string to populate a field in newform.aspx (which i have done on sharepoint 2013 with code i have found here on)
Unforuntaly with sharepoint online/365 This code was no longer working.
This code has fixed my issue (though it does change how a few previous pages are constructed)
Appologies if this doesn't directly answer the above question (as this was me trying to breakdown the overall issue i was having into something simpler and easier to address based on me narrowing down the issue in my original code) however as I am now up and running, it seems only polite to post the outcome.
Prior to code, i have a projects list with a "ProjectName" field. I was sending the field name into a URL and querystring to get mylist/newform.aspx?ProjectName=Test2
I was then trying to pull that Test2 into the lookup field (liked to the project list) "ProjectName" in the list "MyList"
But even when loading the function for my old script with _spBodyOnLoadFunctionNames.push() it wasn't working.
After playing with this for a while and after some looking around i found this peice of code
<script type="text/javascript">
(function () {
var ctx = {};
ctx.Templates = {};
ctx.Templates.Fields = {
'ProjectName': {
'NewForm': renderTaskCategory
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctx);
})();
function renderTaskCategory(ctx) {
//extract cat parameter from a query string
var GetProjID = GetUrlKeyValue('ProjID');
//set lookup field value
ctx.CurrentFieldValue = GetProjID;
//default template for rendering Lookup field control
return SPFieldLookup_Edit(ctx);
}
</script>
This means that i have to change my previous url builds to create mylist/newform.aspx?ProjID=2
This script then finds item ID 2 (which happens to be test2 in this case) and puts the title of item 2 in my lookup field ProjectName
Thanks again to those that helped earlier.
And apologies again if this doesn't directly answer the question i originally asked.
I'd like to search using savedsearch.
Here my code snippet goes.
var searchresults = nlapiSearchRecord('item', search_id, null, null);
search_id is defined as parameter in text field.
This is suitelet script so if you couldn't find similar search_id in savedsearch then it throws exception.
To avoid this I'd like to check if there is any similar internal id in saved searches.
For instance if there are two saved searches which ids are customsearch1, customsearch2.
If search_id is 'cust' then it throws exception and script finished with error.
It shows this in script log
'That search or mass update does not exist.'
Looking forward to hearing from you soon.
Regard
You can do a saved search of saved searches. You could take the results and use regex to determine if there is a similiar one. Use trim plus regex.
You could prevent this by changing your search_id parameter to a List/Record of Saved Searches.
Any reason why it has to be a text field?
I have a page that lists out items according to numerous parameters ie variables with values.
listitems.php?color=green&size=small&cat=pants&pagenum=1 etc.
To enable editing of the list, I have a parameter edit=1 which is appended to the above querystring to give:
listitems.php?color=green&size=small&cat=pants&pagenum=1&edit=1
So far so good.
When the user is done editing, I have a link that exits edit mode. I want this link to specify the whole querystring--whatever it may be as this is subject to user choices--except remove the edit=1.
When I had only a few variables, I just listed them out manually in the link but now that there are more, I would like to be able programmatically to just remove the edit=1.
Should I do some sort of a search for edit=1 and then just replace it with nothing?
$qs = str_replace("&edit=1, "", $_SERVER['QUERY_STRING']);
<a href='{$_SERVER['PHP_SELF']}?{$qs}'>return</a>;
Or what would be the cleanest most error-free way to do this.
Note: I have a similar situation when going from page to page where I'd like to take out the pagenum and replace it with a different one. There, since the pagenum varies, I cannot just search for pagenum=1 but would have to search for pagenum =$pagenum if that makes any difference.
You can use parse_str() to parse the query string, remove the unwanted parts and build the new one via http_build_query() like this
parse_str($_SERVER['QUERY_STRING'], $params);
unset($params['edit']);
$new_query_string = http_build_query($params);
I'm writing a Dashboard widget in Dashcode, and on the back side, I've got a string for credits. I want to include the widget's version number in that string, but if possible, I want to programmatically grab it from the CFBundleVersion or CFBundleShortVersionString key in Info.plist to avoid having to change the number in multiple places if and when I update the widget.
Searches on Apple's developer documentation, Google and various forums have proven fruitless so far. What I'd like to know is whether there's a built-in way to do this that Apple included but forgot to mention (like var version = widget.version(); or something), or whether my script will have to pull in and parse the entire plist before plucking out the one value I actually want.
Thanks for any help you can provide!
I seem to have found the answer: use Dashcode's "data source" facility to read in Info.plist as an XML data source. From there, this blog post showed me how to traverse the plist's structure and get the correct string (in this case, the fifth <string> element in the file, corresponding to CFBundleShortVersionString.
The function I ended up with:
function getWidgetVersion() {
var dataSource = dashcode.getDataSource("infoPlist");
var version = dataSource.selection().valueForKey("dict").valueForKey("string")[4]; // This line and the previous could probably be combined for the sake of brevity
if (typeof(version) == 'string') {
document.getElementById("creditsLabel").innerHTML += version; //I'll change this to just pass the number on
}
}
Since the text of the creditsLabel div has already been started off with a localized string, I get a nice little label saying "Version 1.0".
I've read the YQL guide, and I keep reviewing http://developer.yahoo.com/yql/guide/yql-o...entables-paging and I have been looking at a few examples, but I'm still left pretty confused how YQL paging works.
The problem that I am trying to tackle is creating a YQL open data table for the Mozilla labs Jetpack Gallery's jetpacks pages http://jetpackgallery.mozillalabs.com/jetpacks
You flip through the pages of jetpacks with the ?page query variable and there is an order_by query variable. You can only see 10 results per page.
Questions:
List item
Should I use or ?
How do I specify the query parameter that indicates the page? in this case it is the 'page' query parameter.
I am assuming I should use: <urls><url>http://jetpackgallery.mozillalabs.com/jetpacks</url></urls> is this correct?
In the execute element, I will need to extract the details for each jetpack on the page? if so how would I organize that for the response.object?
Can anyone provide some help? or perhaps point to a data table that I can look at as a reference? or better documentation on how paging works?
Firstly, you should be looking at the paging model (Your link got compressed above, so I'm just putting it here.
When you use the paging with no <execute></execute> block specified, it will be used in the query string with the URL specified in <url></url>. Just play with the Flickr Photo Search Example, you have to run it in the Console with Diagnostics turned on to look at the changes in the URL. The id attribute is used to insert the number in the query. Just to illustrate here, the paging portion looks like this:
<paging model="page">
<start id="page" default="0" />
<pagesize id="per_page" max="250" />
<total default="10" />
</paging>
For example, querying
select * from flickr.photos.search(10,20) where has_geo="true"`
The URL used was http://api.flickr.com/services/rest/?method=flickr.photos.search&has_geo=true&page=1&per_page=30. As you can see, it actually took the page=1 but asked for per_page=30 and internally truncated the first 10 results so that you get an offset of 10 and a total of 20 results.
The reason why YQL did this is because the model selected is page.
Another example, if you attempt to do this:
select * from flickr.photos.search(249,2) where has_geo="true"
YQL will retrieve both ...&page=1&per_page=250 and ...&page=2&per_page=250 (I've shortened the urls for illustration) as expected to get the results.
The paging variables are also defined in the global scope if you use JavaScript in <execute></execute> section. You can see this being used in the flickr.photos.astro OpenData Table.
I guess that should answer the question for you, since I see that on GitHub, you have been working on how to extract the pages using XPath.
For your case you should have something like:
<paging model="page">
<start id="page" default="1" />
<pagesize id="per_page" max="10" />
<total default="10" />
</paging>
The per_page would be in your internal query but it's used for the YQL to determine the queries needed. Then in your JavaScript could probably do something like:
y.query(
"select * from html where url=#url",
{url: "http://jetpackgallery.mozillalabs.com/jetpacks?page=" + page}
);