Auto-populate source field on hr case

Vaishali 11
Tera Guru

I have a requirement where the Source field of the HR case should get auto-populated based on how it's getting created. For ex- if the case is being raised over voicemail then the source should auto-populate as phone. How can this be achieved?

 

Thanks!!

1 ACCEPTED SOLUTION

@Vaishali 11 

It's not possible to auto populate when somebody calls the helpdesk number or sends voicemail.

It's possible when we know the source of record

In case of call or voicemail the agent will be setting the HR case form fields, so it's responsibility on that agent.

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

View solution in original post

7 REPLIES 7

Sandeep Rajput
Tera Patron
Tera Patron

@Vaishali 11 You need to populate the source in the script which is responsible to create the case when the case was raised via voicemail. 

Hi @Sandeep Rajput could you please tell which script you are referring to?

Juhi Poddar
Kilo Patron

Hello @Vaishali 11 

If you need to populate the Source field when creating the HR case via a script (e.g., in the script responsible for case creation), you can directly set the value of the Source field in that script based on how the case was raised.

Example script:

var hrCase = new GlideRecord('sn_hr_core_case');  // Create a new HR case record
hrCase.initialize();  // Initialize the record

// Assuming you know the case creation method, e.g., 'Voicemail'
var caseCreationMethod = 'Voicemail';  // This value can be dynamically set

// Set the source field based on the case creation method
if (caseCreationMethod == 'Voicemail') {
    hrCase.setValue('source', 'phone');  // Set the Source field to 'phone' for voicemail
} else if (caseCreationMethod == 'Email') {
    hrCase.setValue('source', 'email');  // Set the Source to 'email' for email
} else {
    hrCase.setValue('source', 'other');  // Default to 'other' if the creation method is unknown
}
// Populate other necessary fields

// Insert the record into the table
hrCase.insert();

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

Hi @Juhi Poddar could you please explain to which script you mean to add this and also how can we do the identification if the case is coming from voicemail?