0
votes

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

2

2 Answers

0
votes

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,

$Result.<<Name of your action call goes here>>

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.

0
votes

I believe that BrowserDocumentComplete fires each time either a page or an iframe finishes loading. Instead, use an event that generally only fires once, like DataReady or PageReady. This assumes that DataReady and PageReady are available in your version of USD.

DataReady and PageReady can still fire multiple times during reload / refresh scenarios, so you can still have the same problem. To mitigate this, check for the existence of the data parameter that is created when the record is created. In the condition check, allow the replacement parameter to be replaced by an empty string when it doesn't exist, using the '+' modifier. If your Action Call is named "Create Custom Entity Record", then your condition expression will probably look something like this:

[[$Result.Create Custom Entity Record]+]===""

Now, even if the Action Call is attempted multiple times, it should only fire once and be prevented from firing subsequently. Subsequent attempts should be shaded yellow in Debugger, indicating "ConditionFailed".