CRM opportunity workflow custon field increment

Hi

We have created a field on opportunity for licence number

In my workflow step I want the licence number to populate  the next number when I get to that stage.

Please guide on how this can be achieved

Thankyou

  • 0

    Hi BCSKZN

    One way you could do is to have a 'holding' field somewhere, depending on how it needs to increment you could add a System Parameter value, or lets say it is unique to the customer you could hold it on the Company record (just not shown on screen. 

    I would then advise creating a Stored Procedure as you can then do bits with it - calling on it with the Execute SQL Statement - you can fetch the value from the field (if null return '1') and update your record, then go back to the holding field and increase it by 1 for the next time

  • 0

    Assuming it will work, you'll probably want a create script but these might not be easy on a workflow screen. I haven't tried. On screen load it will run a query to find the max number and then add 1 to it. Something like this (untested)

    var Query;
    Query = CRM.CreateQueryObj("Select max(oppo_field_of_choice) from opportunity", "");
    Query.SelectSql();
    if (!Query.eof)
    {
    DefaultValue = Query("oppo_field_of_choice");
    }

  • 0 in reply to Matthew Shaw

    Here is an example, I have a 'Training Course' which has delegates on it, but at a certain time I want to give them a Certification No. So mine is unique per Training Course (as courses themselves have unique number)

    If the number hasn't been provided before - to make sure there are no gaps in the numbers, or changing the existing one by mistake. It grabs the CourseCode from the Training Course + the 'DelegateNo' which is the sequence field.

    Updates the course delegate and then turns to the training course to update it for next time