I am working on a process that allows a user to enter an order using an editable

Certified Senior Developer
I am working on a process that allows a user to enter an order using an editable grid. Using the SAIL Recipes as an example, I created 2 SAIL Rules. One contains the editable grid (psh_itemRows.txt) and the other is the main expression (psh_enterOrder.txt) that calls it. In my editable grid, the user can enter multiple rows and the system calculates the suggestedPrice value based on the user-entered values for 'quantity' and 'unitPrice'. All data is saved in the CDT (which is set to 'multiple') except for the calculated value. I'd also like to display the subtotal in the psh_itemRows.txt form so the user knows how much the total is as he/she is entering line items, but haven't been able to get that to work (probably because the suggestedPrice calculation is not being saved). At the very least, I need to show the subtotal on the main form. Any suggestions? I've attached my SAIL forms.

psh_enterOrder.txt

OriginalPostID-223011

OriginalPostID-223011

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    Sikhi - I'm still having refresh issues with these rules. When the user goes back to the main screen (form), The ri!newRIP_cdt.clinSubtotal value is displayed (subtotal of the line items costs' which is captured in the preceding script task). The user is then tasked to enter values for handling and freight charges:
    ri!newRIP_cdt.totalEstimate = ri!newRIP_cdt.handlingCost + ri!newRIP_cdt.freightCost + ri!newRIP_cdt.clinSubtotal
    ri!newRIP_cdt.handlingCost is calculated using the ri!newRIP_cdt.handlingRate * ri!newRIP_cdt.clinSubtotal OR the user can overwrite the handling cost value.
    Issues:
    1. If I enter a handling rate, the handling cost is properly calculated and ri!newRIP_cdt.totalEstimate value updates.
    2. If I overwrite the handling cost value, the ri!newRIP_cdt.totalEstimate value does not update.
    3. When I enter a freightCost, the ri!newRIP_cdt.totalEstimate value does not update.

    I updated the totalEstimate value in the other parameters' 'saveInto' section as you suggested previously but I must be missing something. Can you take a look at my code? (This is just a portion of the form but it includes the SAIL code for these fields).

    Values Not Refreshing.txt


  • @judym May I please know the data types of the handlingRate, handlingCost, freightCost and totalEstimate fields?
  • 0
    Certified Senior Developer
    They are all Num(Dec) in the CDT (double(19,2) in the table.
  • @judym In that case, would you please be able to remove the dollar function everywhere(in the calculations being made in 'saveInto' attribute and from the 'value' attribute of editable fields) and store the calculated values directly without any further formatting? Please do let me know if you need any assistance in terms of code.

    A problem I could see as of now is, the fields into which you are trying to store values into, are of type Number Decimal whereas the values which you are trying to store are of type Text. You might find success in storing a Numeric value into a field of type Text but the vice-versa may cause an weird behavior and lead to erroneous results as far as my knowledge is considered. So I would suggest refraining from making use of fn!dollar() function which actually converts the numeric value to text.
  • 0
    Certified Senior Developer
    I removed the dollar function from all the saveInto attributes but still the only one that updates is when I enter a handling rate. That updates the totalEstimate -if I delete the handling rate or cost - the totalEstimate doesn't update. Do I need to make the fields a type 'Floating Decimal' instead of Text? Why would the total update when the handling rate field changes but not for any other updates?
  • 0
    Certified Senior Developer
    I got it! I tried changing the type to a floatingPointfield but that didn't help. What I needed to do is recalculate the total estimate value using all the possible calculations. It's finally updating the total estimate value.
    if(ri!newRIP_cdt.clinSubtotal = "", 0, dollar(ri!newRIP_cdt.clinSubtotal +
    (if(ri!newRIP_cdt.handlingCost = "", (if(ri!newRIP_cdt.handlingRate = "", 0,(product(product(ri!newRIP_cdt.handlingRate, 0.01), ri!newRIP_cdt.clinSubtotal)))), ri!newRIP_cdt.handlingCost)) +
    (if(ri!newRIP_cdt.freightCost = "", 0, ri!newRIP_cdt.freightCost)))),