Info Message on form when related record is deleted

Pranavi07
Tera Expert

Hello all,

We have service commitments (service_offering_commitment) attached to service offering(service_offering)  as a related list and currently only admins have the ability to remove commitments.

We have added a delete ACL so that certain users having a particular role can remove the service commitments from service offering. And they can delete/remove using edit button in the related list of service offering. This is done but whenever a commitment record is removed, we would like to show an info message on service offering form. How to achieve this? Please help

so_sc_com.png

1 ACCEPTED SOLUTION

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Pranavi07 

By using Business rule you can achieve this

Create one business rule on "service_offering_commitment" this is relationship table of servicefoffering and commitment.
BR condition - before delete

In script you can add InfoMessage like below

Screenshot 2023-11-20 at 11.40.11 AM.png

Please try this once and Mark Helpful and Correct if it really helps you.

View solution in original post

5 REPLIES 5

Hi @Pranavi07 

try below code once

var serOff = new GlideRecord("service_offering");
    serOff.addQuery('parent', current.u_business_service);
    serOff.query();
    while (serOff.next()) {
        var OffCom = new GlideRecord("service_offering_commitment");
        OffCom.addQuery('service_offering', serOff.sys_id);
        OffCom.addQuery('service_commitment', current.u_service_commitment);
        OffCom.query();
        if (OffCom.next()) {
            gs.addErrorMessage("There are Service Commitments with name" + current.u_service_commitment.name + " in the Service Offering " + serOff.name + " Delete those first to delete the Service Commitments from this BS");
            current.setAbortAction(true);
        } else {
            gs.addInfoMessage("The commitment has been deleted from Business service");
        }

    }

Please let me know if it helpful or not.