how to enter a rate that is a percentage (for disc...
# ask-stanley-ai
e
how to enter a rate that is a percentage (for discounts or markups) via SuiteScript? Invalid Field Value occurs when it is a percent (%)
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that when setting a rate as a percentage for discounts or markups via SuiteScript, you should avoid using the '%' symbol. Instead, you should only use the numeric value. For example, if you want to set a discount rate of 5%, you should only pass the number 5, not '5%'. Here is an example of how you can set the rate:
Copy code
javascript
rec.setSublistValue({
    sublistId: 'item',
    fieldId: 'rate',
    value: 5, // not '5%'
    line: lineCount
});
If you want to set a negative percentage, you can do so by passing the negative number. For example, for a discount rate of -5%, you should pass -5.
Copy code
javascript
rec.setSublistValue({
    sublistId: 'item',
    fieldId: 'rate',
    value: -5, // not '-5%'
    line: lineCount
});
However, if you want to set the rate as a string, you can use the
setSublistText
method instead of
setSublistValue
. Here is an example:
Copy code
javascript
rec.setSublistText({
    sublistId: 'item',
    fieldId: 'rate',
    text: '5', // not '5%'
    line: lineCount
});
Please note that the rate field accepts number data, and the 'Invalid Field Value' error occurs when the value is not a number or a valid string representation of a number. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.877882421
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863292
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.856646597
Please provide your feedback on this answer.