I am trying to built a logic where I am running an action call with uii action CreateEntity. The action call creates a record in CRM Custom Entity. Now, the action call is being fired multiple times and that is because it is attached in the BrowserDocumentComplete Event which is being fired multiple times.
Now since that action call is being fired multiple times therefore multiple records are being created inside CRM. I want to make it stop after it creates the first record and what happens is if it creates a first record a parameter is created inside USD DataParameters.
So, I want to check through Scriptlet preferably that if the parameter lets name it RecordCreated has been created inside USD then make the action call stop.
Something like this if (RecordCreated Exists) then stop else run
Ideally BrowserDocumentComplete event won't get triggered multiple times in USD. Is it the PageLoadComplete event normally gets triggered twice. That is something which you need to check once before thinking of another solution.
Coming to your issue, if the browser document complete is not working as expected in your case, another option is to do a check whether the record is created before running the action call the second time. For that what you can do is, whenever an action call is executed you will get an object $Result in the USD data parameters. Look for the object and get the guid of the CRM record being created. You should be able to access that something like this,
In your same action call, check whether the output of the above code and see whether that is empty of a GUID. If its not empty that means your action call was executed previously, otherwise execute the action call to create the record.
Hope that helps.