Copy fields value from CSM case to task

Hafsa1
Mega Sage

I have written very simple code to copy fields values from CSM case to task but seems not working . I'm creating case task manually using "New" button in related list tab.

Its BEFORE, INSERT business rule without any condition

Hafsa1_0-1778215612666.png

Is there anything I am missing?

2 REPLIES 2

VaishnaviK3009
Kilo Sage

Hi @Hafsa1 ,

In some cases, while creating CSM Tasks manually using the “New” button from the related list, the parent_case field gets populated correctly but getRefRecord() may not fetch the Case record properly in a BEFORE INSERT Business Rule.

Used an explicit GlideRecord query :

(function executeRule(current, previous) {

    if (!current.parent_case)
        return;

    var caseGR = new GlideRecord('sn_customerservice_case');

    if (caseGR.get(current.parent_case)) {

        current.account = caseGR.account;
        current.contact = caseGR.contact;
        current.consumer = caseGR.consumer;
        current.consumer_profile = caseGR.consumer_profile;
        current.short_description = caseGR.short_description;
        current.description = caseGR.description;
    }

})(current, previous);

Also worth checking:

  • Business Rule is Active and running on Before Insert
  • parent_case is available before insert
  • Target fields are writable and not overridden by OOTB logic

Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.

Regards,
Vaishnavi
Technical Consultant

@VaishnaviK3009 No this is not working. Actually parent_case is showing blank as task is not created yet