Applies To:
CPQ
Summary:
In many cases, CPQ requires the use of a custom field to capture user-entered data. In order to maintain the data integrity of the cart and cart calculations, it is possible to implement checks around the custom fields to either clear non-numeric entries or display an error message to the user.
Solution:
One way to display an error message is to include a formula like the following in the numeric field:
[IF]([AND]([NEQ](<*CTX( Quote.CustomField(Input Percentage) )*>,0),[NEQ](<*CTX( Quote.CustomField(Input Percentage) )*>,),[EQ](<*CTX( Number(<*CTX( Quote.CustomField(Input Percentage) )*>).Raw )*>,0))){Not A Number}{Its a Number}[ENDIF]
Another option is to use Python on field change:
if Quote.GetCustomField("Input Percentage").Content != '':
try:
float(Quote.GetCustomField("Input Percentage").Content)
except Exception:
WorkflowContext.Message = 'Input Percentage is Not a Number'
WorkflowContext.BreakWorkflowExecution = True
#or:
Quote.GetCustomField("Error Field").Content = 'Input Percentage is Not a Number'
Quote.Save()