Need to write a script for cascade deletion, Engagement records should be deleted when vendor delete

bejawada
Tera Contributor

Hi Community,

 

I have a requirement to provide an option of Delete button on Vendor Records for Vendor Manager role.

Whenever the delete button clicks associated Engagements should also get deleted. The delete functionality should be available on Vendor Management workspace.

Please help me in writing script for workspace delete button.

 

Thanks.

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @bejawada 

you don't need to script anything. just make sure that the respective cascade delete rules are set correctly. Then ServiceNow will delete referencing records automatically in case the parent records gets deleted.

See https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/administer/field-adm...

Maik

View solution in original post

10 REPLIES 10

Maik Skoddow
Tera Patron
Tera Patron

Hi @bejawada 

sorry, but it is still not clear what you have done.

"I have used the below UI Action script in my environment and make it visible on the Form" --> makes no sense, as the "Delete" button is visible by default and there is no need to customize anything.

So why cannot you explain exactly WHAT you have done and WHY.

Maik

Since Global DELETE UI action is restricted to  limited roles, I want a DELETE UI action to be given to TPRM Manager role on core_company table. So I have created a custom UI Action on core company table.

Since TPRM Managers will be using "Vendor Management Workspace" for operating, I have used workspace client script shown in the screen shot.

bejawada_0-1692676042606.png

Let me know if this is enough or please suggest if we have any alternate approach for deleting records on workspace.

 

Thanks. 

Again, there is no need to customize/implement something.

If you want users with a certain role to delete records on a certain table, you just have to add the respective ACLs. Then the OOTB "Delete" button will be visible in the Workspace.

Maik

Hello @Maik Skoddow ,

 

I have followed the steps that you have guided.

Step1: Created a User(TPRM Manager) and gave him a role(sn_vdr_risk_asmt.vendor_risk_manager).

Step2: Modified the Delete ACL and added the above role

bejawada_0-1692688820447.png

Step 3: Modified the cascade rule of the field "Vendor" in Engagement table.

bejawada_1-1692688992981.png

 

Step 4: Impersonated with TPRM Manager 

Step 5: created a Vendor Record(Test Vendor)

Step 6: Created an Engagement for "Test Vendor" as "Test Engagement"

Step 7: Opened the Workspace under Vendor Management Application.

Step 8: Open "Test Vendor" Vendor record and clicked on Delete Button.

Step 9: Both Vendor and associated Engagement got deleted. At the same time a new empty vendor got created automatically.

bejawada_2-1692689409764.png

I am not sure how is this empty record getting created. 

Note: This empty record is getting created only when impersonated with TPRM Manager. No records are getting created when admin delete Vendor.

This is happening only when record deleted from Workspace.

All of these are happening in PDI as well, I have tried in my PDI and here also an empty record is getting created automatically.

Please let me know if anything else needed.

 

Thanks.

 

Hi @bejawada 

thanks for the extensive explanation of the issue which is bizarre enough to have no good answer for you. Now I would have to go on your instance myself and try to find the cause. Everything else would be just guesswork and not serious.

Maik