CPM script running recursively

I have written a CPM script that runs on Incident update and checks for the value of a custom field. If the value is 1, it updates the incident. Everything works fine except the fact that whenever I update and save the incident, the incident thread gets updated 5 times.

I have added the below line of code already.

if ($cycle !== 0) return;

But, this does not help. I have also noticed that, if at the end of the code that updates the incident, I make the custom field value as 0, it does not update the incident multiple times. But, this does not looks logical and moreover, I do not want to make the value of the custom field again to zero

Can anyone please suggest some solution here.

Comments

Only running on the 'zeroth' cycle should keep the CPM from cycling multiple times after an update. Can you provide your code? I would try logging the parameters that are passed to the apply() function immediately, and inspecting the results.

Hi John,
I am also facing the same issue. Everything works fine except the fact that whenever I update and save the incident, the incident thread gets updated 3 times. Even i logged the cycles values in every call the cycle value is ZERO only, so if i use
if($cycles!==0) return; it won't work and it will execute total function.
Could you please suggest me how to stop the Multiple calls.
Any small help it would be great helpful.

Thanks in advance.

Thanks and Regards
Narendra Muttineni

Zircon - This is a contributing Drupal Theme
Design by WeebPal.