Workflow on sales order price change

SUGGESTED

I am trying to create a workflow to trigger when the net price on a sales order line has been changed. I would like the workflow email to contain both the value before the change and the value after. I am close, but seem to not be able to capture the correct line. If there are 3 lines on the sales order, I get 3 emails when I only want 2 email with the information from the line which the price was changed. 

Here is my workflow and data model. Any suggestions? 

  • 0
    SUGGESTED
    It could have something to do with the "type" under the conditions. You have this set to header, when it should be line level workflow. In this case, it will evaluate the condition based on each line instead of the header (all lines).
  • 0 in reply to Michael91
    Thanks for the suggestion! I changed from header to line, but I still receive an email for each line in the order. I only want one email containing only the one line that the price was changed on. Sorry for my mistype on the original question stating I wanted 2.
  • 0

    Hi Bolta_TJ,

    I was wondering if you ever got this workflow to work.  I am trying to create a similar workflow but with the SO Delivery date field but having different issues.  Seems to display a workflow even if the date wasn't changed and then it is dsiplaying the changed date as the first date entered originally.  I'm wondering if this is even possible now.

    If you have any feedback would greatly appreciate.

    Thanks!

    Christine

  • 0 in reply to Christine T.
    SUGGESTED

    #You would have to write a function like this a nd call it as below and save it in a file YFUNCS

    #The message part is as below:

    ####################################################################

    Order |[F:SOH]SOHNUM | has been updated by |GUSER| Date and Time |Datetime$|

    |FUNC YFUNCS.PRICE_CHANGES()|

    #########################################################

    #The function is as below

    Funprog PRICE_CHANGES()
    Local Char ALL_CHANGES(250)

    ALL_CHANGES='Price Changes: ' +chr$(13) + chr$(10)
    For [F:SOP] Where SOHNUM=[M:SOH0]SOHNUM
    ALL_CHANGES += num$(SOPLIN/1000)+': '+ num$([F:SOP]NETPRI) +' TO '+ num$([M:SOH4]NETPRI(SOPLIN/1000))+chr$(13) + chr$(10)
    Next
    End ALL_CHANGES

    #For more help email [email protected]

  • 0 in reply to ardzimano

    thanks for reply but I don't understand where would this code be placed?

  • 0 in reply to Christine T.
    SUGGESTED

    You would place it in a Script called YFUNCS under Development ->Script Dictionary->Scripts->Script Editor. Then Compile it. For more help email [email protected]

  • 0 in reply to ardzimano

    I think this not will work allways, for example. We have a Sales Order with two lines, then we have lines:

    • 1000
    • 2000

    Then the user insert betwen first and second, then we have:

    • 1000
    • 1500
    • 2000

    1500/1000=1,5 OMG!  ;) Also the first element of a grid is 0 and not 1.

    I think you need a function but maybe mangae inside action $APRES_MODIF  because I thinkl is the only place where you can ask about [F:SOH4]xxxxx(nolign-1) -old value- with zc -new value- 

    I'm not 100% sure but I think with workflow you can not compare betwen OLD values and NEW values. such as an stored procedure.

    Regards!

  • 0 in reply to Xavier.Buxade

    I am using it right now and it's working. Below is the final function

    Funprog PRICE_CHANGES()
    Local Char ALL_CHANGES(250)

    ALL_CHANGES='Price Changes: ' +chr$(13) + chr$(10)
    For [F:SOP] Where SOHNUM=[M:SOH0]SOHNUM
    If num$([F:SOP]NETPRI)<> num$([M:SOH4]NETPRI(([F:SOP]SOPLIN/1000)-1))
    ALL_CHANGES += 'Line # '+ num$([F:SOP]SOPLIN/1000)+': '+ num$([F:SOP]NETPRI) +' TO '+ num$([M:SOH4]NETPRI(([F:SOP]SOPLIN/1000)-1))+chr$(13) + chr$(10)
    Endif
    Next
    End ALL_CHANGES

  • 0 in reply to ardzimano
    SUGGESTED

    Hi ardzimano,

    My big doubt now (if you are 100% sure this is working) is that when  workflow is executed the changes are not stored in database. But what I remember, for example workflow creation we use [F:xxx], then is after write. I don't now if in update is previous ReWrite (could you confirm please?),  but if its after then take a look of that:

    Other recommendation maybe is this: Since in X3 we have Clob vars  and workflow message field is like this:

    maybe is better to define your variable ALL_CANCHES like this: Local clbfile ALL_CHANGES(5) Because for example if you have this kind of prices 3,2 

    Line # 1: 100.00 TO 100.00

     You will not inform more than 10 lines. 

    BUT I'll prefer to create a new field in SOP table called ZNEWPRICE, then with APRES_MODIF check with zc and [M:SOH4] if have change and is not a new line. Then the workflow will be by line with a simple condition (ZNEWPRICE<>0). This will give more freedom to consultants or customers to design the text and also you could the new price in the workflow monitor. 

    Also you will give more functionality to your customer, for example: 

    • Crete a User Query with the Orders changed you can filter UPDDAT=Date-1 or whatelse
    • Create a Portal with a query with the Orders changed you can filter UPDDAT=Date-1 or whatelse. (versions higher V6).
    • Create reports and send by email.

    And Writting this to you, other idea comes to my mind, maybe you can use  the auditory table and work with that. (available since V5)

    Best Regards,