SAP Knowledge Base Article - Public

3234848 - CMT : How to Enforce Numeric Entries in a Custom Field

Symptom

How to Enforce Numeric Entries in a Custom Field

Resolution

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()

 

 

Keywords

KBA , CEC-SAL-CPQ , Sales Cloud CPQ , How To

Product

SAP CPQ all versions