Skip to main content
sunus0001
November 10, 2021
Solved

Validation not working as expected after changing the field name

  • November 10, 2021
  • 13 replies
  • 1 view

Hi Appian team,

I have changed the display name for CDT and there for modified the field name in interface as well. I have done the below code change, but the regular expression added for validation is not working as expected.

Can anyone help me out to solve this issue?

below is the code snippet used.


a!textField(
label: "Purchase order (PO)/Sales order (SO)/STO/Requisition",
labelPosition: "ABOVE",
value: trim(
index(
ri!PF_Request,
"Order_Del_Number",
null
)
),
saveInto: {
a!save(
ri!PF_Request.Order_Del_Number,
/*if(ri!PF_Request.GBEID=18,*/
/*left(*/
/*trim(*/
/*save!value*/
/*),10),*/
/*trim(*/
/*save!value*/
/*))*/
trim(save!value)
)
},
required: true,
validations:if(ri!PF_Request.GBEID = 18, if(regexmatch("^([0-9]{1,10})$",ri!PF_Request.Order_Del_Number),null,"The number provided should not contain any special character and can have upto 10 digits"), null )


)

Also please see the below discuss link to understand what are the changes I have made.

Thanks

Sunu Sam

https://community.appian.com/discussions/f/process/22377/how-can-i-just-give-a-display-name-to-columns-in-cdt-which-has-a-different-name-in-database-tables-also-i-have-more-questions-regarding-appian-features/87736#87736

Best answer by richardm900458

is your "ri!PF_Request.GBEID = 18" fine?

13 replies

richardm900458
November 10, 2021

Hi sunus,

1.) please try this function for inserting code. It helps the reader a lot to understand your code

2.) What kind of behavior do you expect?  

sunus0001
sunus0001Author
November 10, 2021

a!textField(
label: "Purchase order (PO)/Sales order (SO)/STO/Requisition",
labelPosition: "ABOVE",
value: trim(
index(
ri!PF_Request,
"Order_Del_Number",
null
)
),
saveInto: {
a!save(
ri!PF_Request.Order_Del_Number,
/*if(ri!PF_Request.GBEID=18,*/
/*left(*/
/*trim(*/
/*save!value*/
/*),10),*/
/*trim(*/
/*save!value*/
/*))*/
trim(save!value)
)
},
required: true,
validations:if(ri!PF_Request.GBEID = 18, if(regexmatch("^([0-9]{1,10})$",ri!PF_Request.Order_Del_Number),null,"The number provided should not contain any special character and can have upto 10 digits"), null )


)

ok added the code as you advised,  but expected behaviour is validation should work.

richardm900458
November 10, 2021
is validation should work.

love this answer [emoticon:44a8a53ad3364ea78a16c5a3229f75bb] but what do you define as " should work". What is the target of your evaluation?
I can try to explain the general behavior of regexmatch()
if your string ri!pf_request.order_del_number contains all the signs of "^([0-9]{1,10})$" then the return value will be true. If one of them is not included, the returnvalue will be false.
simple examples:

  • regexmatch("helo","Hello") = true
  • regexmatch("h","Hello") = true
  • regexmatch("heli","Hello") = false
  • regexmatch("hal","Hello") =false