Issue assigning variable

Randy33
Tera Guru

I am having an issue assigning the value for the configuration item field in outages using a inbound action script.

// No Outage Found - Create Outage

        var newOutage = new GlideRecord('cmdb_ci_outage');

        newOutage.initalize();

        newOutage.u_status = 'open';

        newOutage.type = 'outage';

        newOutage.u_cmdb_ci = 'TestApp';

        newOutage.u_short_desc = email_subject;

        newOutage.begin = gdt.getDisplayValueInternal();

        newOutage.insert();

 

The CI is setup as a Business Service:

 

Randy33_0-1734539383668.png

How would I assign this?  The below code is not working:
newOutage.u_cmdb_ci = 'TestApp';

1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron
Giga Patron

Hi @Randy33 ,

 

use below script 

 

var newOutage = new GlideRecord('cmdb_ci_outage');

        newOutage.initalize();

        newOutage.u_status = 'open';

        newOutage.type = 'outage';

        newOutage.u_short_desc = email_subject;

        newOutage.begin = gdt.getDisplayValueInternal();

var ci = new GlideRecord('cmdb_ci');

ci.addQuery('name', 'TestApp');

ci.query();

if(ci.next()){

    newOutage.u_cmdb_ci = ci.getValue('sys_id');

    newOutage.insert();

} 

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand

View solution in original post

1 REPLY 1

Anand Kumar P
Giga Patron
Giga Patron

Hi @Randy33 ,

 

use below script 

 

var newOutage = new GlideRecord('cmdb_ci_outage');

        newOutage.initalize();

        newOutage.u_status = 'open';

        newOutage.type = 'outage';

        newOutage.u_short_desc = email_subject;

        newOutage.begin = gdt.getDisplayValueInternal();

var ci = new GlideRecord('cmdb_ci');

ci.addQuery('name', 'TestApp');

ci.query();

if(ci.next()){

    newOutage.u_cmdb_ci = ci.getValue('sys_id');

    newOutage.insert();

} 

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand