We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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();

        }

    }
4 REPLIES 4

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

@mani55 

Did you check the above points?

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

Tanushree Maiti
Tera 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 Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti