Check if INC hs been created in Employee Center or directly in SN

Kasia5
Tera Contributor

Hi All

 

I have a requirement to check if INC has been created in Employee Center or directly in SN.

If in Employee Center portal then I need to set contact_type to Self Service

If directly in SN then I need to set contact_type to Telefon

 

How can I achieve this?

 

Thanks in advance

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Kasia5 

you can use this table to determine if incident got submitted as part of some record producer

Based on that you can set the type. Query that table with your sysId

sc_item_produced_record

AnkurBawiskar_0-1741696256946.png

 

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 tried with after Insert Business Rule:

 

 

(function executeRule(current, previous /*null when async*/) {

    var itemProducedRecord = new GlideRecord('sc_item_produced_record');
    itemProducedRecord.addQuery('task', current.number);
    itemProducedRecord.query();

    if (itemProducedRecord.next()) {
        current.contact_type = 'self-service';
    } else {
        current.contact_type = 'phone';
    }

    current.update();

})(current, previous);

 

but it doesn't work

@Kasia5 

use this -> you should query with current.sys_id and not current.number

(function executeRule(current, previous /*null when async*/) {

    var itemProducedRecord = new GlideRecord('sc_item_produced_record');
    itemProducedRecord.addQuery('task', current.sys_id);
    itemProducedRecord.query();
    if (itemProducedRecord.next()) {
        current.contact_type = 'self-service';
    } else {
        current.contact_type = 'phone';
    }

    current.update();

})(current, previous);

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've changed but still doesn't work