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

Set default source for mobile app HR Case

rafas_10
Kilo Sage

Hi everyone,

 

I was wondering if it was possible to set all HR Cases created via ServiceNow mobile app with the source 'mobile_app' for example without using gs.IsMobile()?

 

Thank you! 

1 ACCEPTED SOLUTION

rafas_10
Kilo Sage

Hi all,

 

I found the following solution:

Business rule 'after' 'insert' on table 'catalog_channel_analytics'.

Conditions:

engagement_channel=mobile^table_nameLIKEsn_hr_core_case^method=create^EQ

 

and script:

(function executeRule(current, previous /*null when async*/ ) {
    var hrCase = new GlideRecord("sn_hr_core_case");
    hrCase.addQuery('sys_id', current.document_key);
    hrCase.query();

    if (hrCase.next()) {
        hrCase.contact_type = "mobile_app";
        hrCase.update();
    }
})(current, previous);
 
And it works 🙂

View solution in original post

8 REPLIES 8

@rafas_10 

but is it using some record producer etc?

how? share screenshot

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

Yes, It's using record producers, as normal. Basically I want when a user submits the record producer in the mobile app, that is creates the case with a specific source. I can't use gs.IsMobile() as the property related to it is set as false

@rafas_10 

is this record producer also used from desktop?

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

rafas_10
Kilo Sage

Hi all,

 

I found the following solution:

Business rule 'after' 'insert' on table 'catalog_channel_analytics'.

Conditions:

engagement_channel=mobile^table_nameLIKEsn_hr_core_case^method=create^EQ

 

and script:

(function executeRule(current, previous /*null when async*/ ) {
    var hrCase = new GlideRecord("sn_hr_core_case");
    hrCase.addQuery('sys_id', current.document_key);
    hrCase.query();

    if (hrCase.next()) {
        hrCase.contact_type = "mobile_app";
        hrCase.update();
    }
})(current, previous);
 
And it works 🙂