Call Script include from Reference Qualifier

amitgaur
Tera Contributor

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'
});

1 ACCEPTED SOLUTION

Sebastian L
Mega Sage

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

View solution in original post

12 REPLIES 12

Vaibhav
Mega Guru

Hi Amit,

 

I have the same problem and solved it by Cross-scope privilege record here we can define what we want to access from the cross scope.

 

Mark it correct/helpful if it helps you

Regards,
Vaibhav Chaudhari

Hi Vaibhav, It is not about the scope or privilege. Something wrong in the way i am trying to call the cript from refrence qualifier or script include function.

Sebastian R_
Kilo Sage

You also have to initialize the script include first (you are missing the parethesis).

Use the following as RefQual: javascript : new x_infte_esm_itemde.MIP_StoreInfo().getStoreIDs(current.variables.requested_for);

Also check if you have to enable the the script include for cross-scope access (depending on the variable).

Hi, Thanks for observing the missing parenthesis. There was one more issue with it though, extra space between 'javascript' and ':'

 

Alok Das
Tera Guru

Hi Amit,

Please give a try with reference qualifier as below:

javascript : MIP_StoreInfo.getStoreIDs(current.variables.requested_for);

 

Please mark my answer as Correct/Helpful based on the impact.

regards,

Alok