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

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@abhi56 

what are you trying to achieve?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

i am trying change backend value of the table taht i gliderecorded 

@abhi56 

can you share your complete widget code and also how are you invoking it ? from where? script for that?

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

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

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