locked
How can I execute a javascript on all opertunities? RRS feed

  • Question

  • HI,

     

    I have implemented a JavaScript function to update custom fields in my opportunities, based on the estimated close date.  This has been added to the onSave event for the form.  In order to populate the fields I need to open and save the opportunities one by one.

     

    Is there a method I can use to execute the function on all opportunities (such as a workflow)?  I have been unable to figure out how to run JavaScript in a workflow and wondered if there is an alternative?  Can I create a workflow to automatically reference the onSave event of each opportunity for example?

     

    Any suggestions would be appreciated.

     

    Regards

    Thursday, November 20, 2008 11:01 AM

Answers

  • ABZ,

     

    There isn't such function to generate client side javascript via workflow.

    Can you rewrite the code through workflow or plugins? Alternatively you may use sql to update the database(UNsupported!)

     

    Cheers,

    Jim

    Thursday, November 20, 2008 11:12 AM
    Moderator
  • Hi David,

    I could see this line by creating an onSave event and then exporting

    Firstly you need to ensure the onSave event is already created and enabled.

    Then export this specific entity (opportunity).

    Search for

    event name="onsave"

    The whole line will be :

    <event name="onsave" application="false" active="true">

    Modify this to

    <event name="onsave" application="false" active="true" BehaviorInBulkEditForm="Enabled">

    ** Somewhat odd, but I've been able to get this working for onLoad, but not onSave, even though the article suggests it should work for onSave.

    You could get it to work by using the onChange event for a test field and inserting the onSave data on that event.

    Cheers,

    Karlo





    Monday, November 24, 2008 2:20 PM

All replies

  • ABZ,

     

    There isn't such function to generate client side javascript via workflow.

    Can you rewrite the code through workflow or plugins? Alternatively you may use sql to update the database(UNsupported!)

     

    Cheers,

    Jim

    Thursday, November 20, 2008 11:12 AM
    Moderator
  • Hi Davie,

    You could perform bulk edit (max 250) on all the opportunity records. Depending on the amount of opportunities, this may/may not be a feasible solution.

    You would need to enable JS for bulk edit. See
    http://www.stunnware.com/crm2/topic.aspx?id=BulkEdit

    Cheers,

    Karlo
    Thursday, November 20, 2008 11:58 AM
  • Thanks Karlo,

     

    Unfortunately this article does not seem to apply to the Opportunities entity, as the line:

     

    <event name="setadditionalparams" application="true" active="true">

     

    ...is not present in the exported XML document.  I double checked my actions by exporting the Account entity where I could locate this line of code, but this is no help in this situation.  I can manually resolve the issue by opening and saving each opportunity in turn and unless you have any alternative suggestions, I will proceed with this action.

     

    Thanks for you advice anyway, the article may come in useful at a later stage.

     

    Regards

     

    David

    Sunday, November 23, 2008 2:17 PM
  • Hi David,

    I could see this line by creating an onSave event and then exporting

    Firstly you need to ensure the onSave event is already created and enabled.

    Then export this specific entity (opportunity).

    Search for

    event name="onsave"

    The whole line will be :

    <event name="onsave" application="false" active="true">

    Modify this to

    <event name="onsave" application="false" active="true" BehaviorInBulkEditForm="Enabled">

    ** Somewhat odd, but I've been able to get this working for onLoad, but not onSave, even though the article suggests it should work for onSave.

    You could get it to work by using the onChange event for a test field and inserting the onSave data on that event.

    Cheers,

    Karlo





    Monday, November 24, 2008 2:20 PM