I'm trying to set an discount amount in the discou...
# administration
p
I'm trying to set an discount amount in the discount rate field on the sales order since there will be a set percentage of discount offered everytime an order is placed. The discount is offered on the entire sales order so I cannot use price level for this. I've a custom field created where I populate the calculated discount amount. I'm trying to copy this in the Set Field Value Action in the workflow, with Trigger On = Before Record Submit. I've tried this After Record Submit as well, but keep getting errors. Field that I'm copying to is Discount Rate. The error that I get is - "You have entered an Invalid Field Value ERROR: Invalid Expression for the following field: discountrate". Has anyone else tried this?
m
Are you using a formula in the workflow to set the field value
If so what is your formula
p
Yes, the custom field Calculated Discount Amount on the sales order, Type is Integer Number, and under Validation, Default Value I've this formula - TO_NUMBER({total}*{custbody_lvl_1_disc}). Here {custbody_lvl_1_disc}, is on sales order and has the percentage. On the workflow, I have {custbody_disc_amt_ke}, which is for Calculated Discount Amount field.
m
I think discount rate is more like a free text field. It acts very strangely as you can put a - or + dollar amount or a - or + percent
Try to make your calculate discount field be a free text field
Or make a second one that is a text value
And see which one works
p
Yes, in my computation I first tried with a '-' sign since I wanted a discount amount that we would need to deduct in the Total Box.
I have an separate field where I've computed, but then how do I get that in the Total Box so I can apply the discount.
m
Like the summary total box?
I thought you were trying to set the discount rate
p
I was, since that is not working, I have another field where I'm calculating the discount amount.
But I can't get that to Total Box on the Discount Item row
m
Can you calculated discount be any value? Or is it just 1 of a few different preset values?
p
It can be any value depending on the total amount times the percentage
m
I’m not sure what you mean by total box can you send a screen shot
p
I'm populating the Discount Item, but cannot copy the discount amount that I calculated to Discount Rate -
m
That total box is calculated by script based off all the total discounts on the order
Its core NetSuite thing
p
So this can't be done by workflow?
Because if I enter the amount on the Discount Rate field, that reflects in the summary/total box
m
I think you can set the discount rate but I feel it’s a matter of field type. Is your calculated discount a percentage of or dollar amount off?
p
dollar amount
its of type = Integer
m
Maybe try this. Make a custom field called text test and make it a free text field
Then add a set field value action after submit that copies your text test field into discount rate
Then set the field to like 20 or something and see if it gives the same error
Actually read this Reddit. I think your field needs to be type currency
p
Thanks, let me try
It's not working and I get this now - "You have entered an Invalid Field Value ERROR: Invalid Expression for the following field: discountrate". So, I set my custom field to type = Currency, and in the formula, TO_NUMBER(-1*({total}*{custbody_lvl_1_disc})).
m
Hmmm
Try unchecking the store value box on the calculated discount field
p
It is unchecked -
Discount Rate is of String type, so that formula should work -
m
It’s so weird
Do you have workflow logging turned on?
I wonder if the logs would say more info
Let me try some tests
Now I’m intrigued. I’ll report back
Ok this worked when i tried it. Set the Calculate Discount field to type = Currency Then select it in the parameters of your set field value action (dont use a formula in the WF action, just select the field in the current record list). LIke this
p
Oh MY! Thanks so much!!! Didn't realize, that the formula in the workflow was causing this!. I had the custom field set to currency and the formula there. So all I needed to do was NOT use the variable in workflow. THANKS!!!
m
👍
145 Views