please let me know any mistake in below code

mani55
Tera Contributor

please let me know any mistake in below code because still it's not working

var reqfor = ritm.variables.requested_for;
    var query = 'model.short_descriptionINSFW100,SFW102^install_status=1^assigned_to=' + reqfor;

    var grService = new GlideRecord('u_alm_service');
    grService.addEncodedQuery(query);
    grService.query();
    if (grService.next()) {
        var ci = new GlideRecord('u_cmdb_ci_service_github_subscription');
        ci.addQuery('assigned_to', grService.assigned_to);
        ci.query();
        if (ci.next()) {
            ci.u_msdn = true;
            ci.update();

        }

    }
3 REPLIES 3

vaishali231
Kilo Sage

@mani55 
Could you please share what is your requirment  ?

Ankur Bawiskar
Tera Patron

@mani55 

model field name is correct within the table u_alm_service?

Should it not be u_model since it's a custom table?

assigned_to is correct field within table u_cmdb_ci_service_github_subscription

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Tanushree Maiti
Mega Patron

Hi @mani55 

 

Add gs.log and check which line is failing.

Also for testing after query() , add gs.log("row count:::::", grService.getRowCount());

 

Also if it returns multiple records, you can see only 1 record as instead of While you have used if.

 if (grService.next()) {

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: