Let's Reconnect, thank you for making 2022 our best year yet.

Look Back
RecordSaving event getting cancelled but still fields are being saved in the object - ISSUE — Cloud Customer Connect
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

RecordSaving event getting cancelled but still fields are being saved in the object - ISSUE

Received Response
23
Views
1
Comments
edited Jun 13, 2022 4:13AM in General Technical Discussions 1 comment

Summary

RecordSaving event not getting cancelled properly.

Content

Hi All,

I am trying to make a REST API call to check for a field value is present in the system or not. I am using fetch/promise. And once that promise is resolved on the basis of the result i am cancelling the event. { I also tried first cancelling the event and then making the fetch/promise thing but did not work for me}

Can anyone let me know what could be wrong with this code?

Version

Oracle Service Cloud 20D (Build 268), Browser UI Version : 3.21.02.12-b0003

Code Snippet

extensionProvider.registerWorkspaceExtension(function(workspaceRecord)
{
workspaceRecord.addRecordSavingListener(function(event){

workspaceRecord.getFieldValues(['Org.Parent','Org.OrgId','Org.C$OrgCode','Org.C$CreatedByAc','Org.C$CreatedByAbc']).then(function(IFieldDetails)
{
						
	var p_org_id = IFieldDetails.getField('Org.Parent').getLabel();
	var org_id = IFieldDetails.getField('Org.OrgId').getLabel();
	var org_code = IFieldDetails.getField('Org.C$OrgCode').getLabel();
	var created_by_ac = IFieldDetails.getField('Org.C$CreatedByAc').getLabel();
	var created_by_abc = IFieldDetails.getField('Org.C$CreatedByAbc').getLabel();
        console.log("p_Org Id(s): ",p_org_id);
	console.log("Org Id: ",org_id);
	console.log("Created by AC : "+created_by_ac+" | Created by ABC : "+created_by_abc);
	if(created_by_ac == "Yes" && created_by_abc == "[No Value]"){							 
           Promise.resolve(checkCodeExists(org_code,"ac",org_id)).then(function(value){
	          var codeExists = value;
		  if(codeExists == "code already exists"){
				console.log(event);
				event.getCurrentEvent().cancel();
			        // alert("Code already Exists in the System");
		  }
		  console.log("Cancelling event: "+event.eventHandler.cancelled);
	   });
	}
	if(created_by_abc ==

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!