GlideRecord Query is not working in service Portal

abhi56
Tera Contributor
i am calling this widget using spmodal
 
spModal.open({
                title: "Select The  ",
           
                widget: 'copya',
                widgetInput:{"asmt":c.data.ins},
 
 
and 

 

 

this is the server script i am using 

 

(function() {
 
 
   
    if(input){
        data.sys=input.asmt;
        gs.addInfoMessage(data.sys);
    }
    //data.sys='16283i02aa1a1474b385130cbb35df'
    var gr=new GlideRecord('custom table');
 gr.addQuery('sys_id',data.sys);
 gr.query();
 if(gr.next()){
   
    //gs.addInfoMessage(gr.getValue('number'));
    data.no=gr.getValue('number');
     
 }
    if(input.submit==true)
    {
        gs.addInfoMessage(input.submit);
        //gs.addInfoMessage(input.userId);
    //gs.addInfoMessage(data.asmtid);
 var gr1=new GlideRecord('custom same table');
 gr1.addQuery('sys_id',data.sys);
 gr1.query();
 if(gr1.next()){
    gs.addInfoMessage('we are setting the userid ');
    gr1.user=input.userId;
    gr1.setWorkflow(false);
    gr1.update();
 
 
 
 
data.no is getting returned but when i am trying to set userid that is not working 
but if i use data.sys='16283i02aa1a1474b385130cbb35df' as this hardcoded that is also working fine 
so my question is if data.sys was passed properly into the widget then the first glidequery should have not worked ,then why first one is working and 2nd one is not ?
is there any alternative way 
 
1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

HI @abhi56 ,

 

Did you try with giving direct value like input.asmt? if not try once.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...
6 REPLIES 6

no input.asmt also not working

@abhi56 

you said it's not working.

Seems you already tried that

Can you share what worked for you since you have closed the thread?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader