How to change ER case subject person

TechnologistTim
Tera Expert

I have tried for far too long to change the subject person after submitting an ER case. I've looked in business rules, client scripts, script includes, field configurations, and ticket header configurations (person row [didn't change any of the headers]). I've tried to look at the widget but I'm awful with code so chatgpt led me down a rabbit hole trying to find data.subject_person which isn't there.

 

Secondly, I have a multi-row variable set with the subject person in it. I'd like to link that person to the subject person field on the case record. I've tried to create a field on the RP that I was going to hide but created it to link it to the case record. I've tried business rules and 2000 different scripts. Nothing is working. Even if I manually input someone in the RP's subject person field (which is mapped), they still don't populate. I have to manually go into the case record and change the person there for it to work. 

 

Thanks ahead of time. I've grown a couple grey hairs off this one lol

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@TechnologistTim 

subject person on case is usually the person who opened it.

Please create after insert business rule on your ER Case table

1) get the MRVS json value

2) parse it and set

Something like this

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

    // Add your code here
    var mrvs = current.variables.mrvsVariableSetName;

    var parsedData = JSON.parse(mrvs);
    var employee = parsedData[0].employeeVariable; // I assume this variable is reference to sys_user
    current.subject_person = employee;
    current.setWorkflow(false);
    current.update();

	// if the variable within MRVS is string then you need to query sys_user and get the sysId and then set the subject person

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

TechnologistTim
Tera Expert

Hmmm. Common sense tells me the subject person is who the case is about, not who submitted it. Why would I want to see opened for and subject person if they're going to be the same person? That is why I'm trying to change that so the subject person is the actual person the allegation is against. 

I used this business rule on the sn_hr_er_case table and it's still not working:

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

     var mrvs = current.variables.involved_parties; // mrvs name

    var parsedData = JSON.parse(mrvs);
    var employee = parsedData[2].subject_person; // 2 because the "employee"/subject_person variable is the 3rd column
    current.subject_person = employee;
    current.setWorkflow(false);
    current.update();

})(current, previous);

Screenshot 2025-02-14 135239.png