How to Pull Parent (sn_customerservice_case) fields into Child Problem record

Brent Hagmayer
Kilo Contributor

We have a new segment of our company using sn_customerservice_case records for their external customer Support Tickets. We have a need for them to open Child Problem records as needed, and I cannot get the Problem form to pull in some of the fields when they create a New Problem record from the related records "Problems" tab I have placed at the bottom of their Ticket form. It pulls in the Parent Task (case) number, but I cannot add fields to the Problem form for Account because it is not listed as an available choice in the slush bucket when customizing the form. I really did not want to create a new fied on the Problem form for Account, I would rather it populate the existing Company field. I even tried allowing the Company field to allow for Class = Company and Class = Account. Currently, since only the Parent Task Number field populates, they have to use the magnifying glass to search through all records to populate the Company field and the Caller (of the Parent Case). How do I get a Child Problem to inherit some of the values of the Parent Case? I have it working fine with Problems that are Children of an Incident.

6 REPLIES 6

Stijn Verhulst1
ServiceNow Employee
ServiceNow Employee

Hi Brent,

technically speaking an Account is a Company in the platform when using the CSM solution, as the Account table is a child table of Company.

The same goes for the Caller field which will be pointing to the User table. A Contact is also implicitly a User, as the Contact table is a child table of User.

My question is to possibly help you further; what are the exact actions an agent used to create a Problem starting from a Case? Is it via a related list at the bottom of the case and do they use the Edit or New button?

Warm regards,

Stijn

Hi Stijn, I have Requests and Problems added to the bottom of the Case form as Related Records and the users have a New button there to create a Child record from the Parent Case. Its how I have all my ITIL related forms (Incident, Problem, Change) and I don't have a problem with any of them. I just can't get the Organization (customer_account) from the Parent Case to the Child Problem or Request. Once I can get that done, I can use the same logic to get the other fields and values from the Ticket, but I am at a road block right now. Thanks for your help.

I see Brent, that's fine. Thank for your input!

 

I hope this will help you:

  • Search for the UI Action New with the Action name sysverb_new, Comments Related List on the Global (global) table. If you see 2, then select the one which has !RP.isInDevStudio() in its Condition field.

  • Change the Table in the UI Action to Problem but don't save yet! Apply an Insert and Stay so you don't destroy the default New button on other Related Lists.

  • Modify the script - this is where you can decide which fields are automatically filled in upon the creation of the new Problem:

    find_real_file.png

    You can modify the query to fill in the Company on your problem such as this, but you'll need to know the technical field names:

    // This is corrected code compared to my screenshot which wasn't accurate enough
    
    // Set the company of the problem = account of the current case
    // Set the caller of the problem = contact of the current case
    
    if (parent.sys_class_name == "sn_customerservice_case") {
    
        var query = 'sys_id=-1';
        query += '^company=' + current.account;
        query += '^caller=' + current.contact;
    
        uri.set("sysparm_query", query);
    
    }

 

Should normally do the trick...

Brent Hagmayer
Kilo Contributor

Hi Stijn, we are so close. The Company field on the Child Problem record is still not populating after making a modified version of the New button. But, the test Short Description is. Two things. I did not know where in the New button script to insert your suggested code, so I am attaching a screen shot of where I put it. And I also bypassed the use of your Condition about the Class of the Parent record. When I added all that in the script, the New button stopped working completely and just redirected me back to the original Parent record (the Case) with no Child Problem being created. It really looks like your code should work. The Company field on the Problem is actually "company" per your script, and the company record on the Parent Case is "account", so you are right on the money with your variable names. But its just not quite working...yet.

find_real_file.png

find_real_file.png