- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2019 01:21 AM
I have a catalog item which has 2 variables 'requested_for' and 'store_no'. Both are reference fields. 'requested_for' is auto populated with logged in user details, it can be changed too. Based on 'requested_for' the 'store_no' field should show only the stores listed for that user. so basically a reference qualifier is needed here. Although it is quite simple, but for some reason my reference qualifier is not able to call the script include(i checked it using script log statements). I have tried all possible ways. Can anyone suggest? Below is the code.
Also, I need to pass the current form 'requested'for' field value(which would be sys_id of user due to reference field) to script include, which i am trying to do in reference qualifier by trying to pass value. I am not even able to call the script include and get to the first log statement "Script Include called " . I am sure there would be something very simple that i am missing 😞
reference qualifier filed of 'store_no' : javascript : new x_infte_esm_itemde.MIP_StoreInfo.getStoreIDs(current.variables.requested_for);
Script Include Name : MIP_StoreInfo
API Name : x_infte_esm_itemde.MIP_StoreInfo
Client Callable : true
Accessible from : All applications scope
Code :
var MIP_StoreInfo = Class.create();
MIP_StoreInfo.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getStoreIDs: function(a){
gs.log("Script Include called ");
var user = a;
var storeID = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',user);
gr.query();
if(gr.next())
{
var allowedStore = gr.u_allowed_stores;
gs.log("Script Include found stores "+ allowedStore);
if(allowedStore != ''){
var storeNo = allowedStore.split(",");
for(i = 0; i < storeNo.length; i++){
var gr1 = new GlideRecord('sys_user');
gr1.addQuery('user_name',storeNo);
gr1.query();
while(gr1.next()){
storeID.push = gr1.sys_id;
}
}
}
}
return 'sys_idIN' +storeID;
},
type: 'MIP_StoreInfo'
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2019 02:37 AM
It seems you are missing the () after the first function call. So it should be:
javascript : new x_infte_esm_itemde.MIP_StoreInfo().getStoreIDs(current.variables.requested_for);
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2019 02:37 AM
It seems you are missing the () after the first function call. So it should be:
javascript : new x_infte_esm_itemde.MIP_StoreInfo().getStoreIDs(current.variables.requested_for);
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2019 03:07 AM
Hi, Thanks for observing the missing parenthesis. There was one more issue with it though, extra space between 'javascript' and ':' . it worked now 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2022 03:16 AM
I Found one more issue along with the syntax error explain by other community member.
var gr1 = new GlideRecord('sys_user');
gr1.addQuery('user_name',storeNo);
gr1.query();
in gr1.addQuery('user_name',storeNo); ,you are trying to find a member from user table which can be matched with store number, this will return nothing, Also please try this separately in script background if this works.