Requirement is I will be entering emailaddresses on UI and it will be passed to the integration and the integration will return the emailAddresses with GUIDs . If any emailaddress is missing from the response which we entered then it must show that emailaddress on UI. Suppose I have passed test@test.com and test2@test.com and In repsonsed I get only GUID of only one emailaddress then it has to show the 2nd emailaddress on the UI as invalid error . How Can I achieve it
Discussion posts and replies are publicly visible
a!localVariables( local!data:ri!Tasr_Requests, local!rawEmails: ri!Tasr_Requests.emailAddresses, local!isintegrationSuccess, local!individualEmails: reject( a!isNullOrEmpty(_), a!forEach( items: split(local!rawEmails, char(10)), expression: trim(fv!item) ) ), local!invalidEmails: reject( a!isNullOrEmpty(_), a!forEach( items: local!individualEmails, expression: if( regexmatch( pattern: "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$", searchString: fv!item, regexFlags: "si" ), null, fv!item ) ) ), /*local!formattedEmailString: a!json({joinarray(local!individualEmails, ",")}),*/ local!formattedEmailString: ( joinarray(local!individualEmails, ",") ), local!validationMessage: if( a!isNotNullOrEmpty(local!invalidEmails), "Emails must be valid and each on a new line.", {} ), local!integrationResult:a!refreshVariable( value: if( a!isNullOrEmpty(local!invalidEmails), rule!Tasr_bulkgetemployees( emails:local!formattedEmailString, onSuccess:{}, onError:{} ), {}, ), refreshalways: true() ), a!formLayout_25r1( label: "Production Validation Request", contents: { a!sectionLayout( contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!boxLayout( label: "", labelSize: "SMALL", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Title:", labelPosition: "JUSTIFIED", value: local!data.requestTitle, saveInto: { a!save(local!data.requestTitle, save!value), a!save( ri!Tasr_Requests.requestTitle, save!value ) }, refreshAfter: "KEYPRESS", characterLimit: 100, required: true, requiredMessage: "Title is Required" ), a!dateField( label: "Start Date", labelPosition: "JUSTIFIED", value: local!data.startDate, saveInto: { a!save(local!data.startDate, save!value), a!save(ri!Tasr_Requests.startDate, save!value) }, required: true, requiredMessage: "Start Date is Required", validations: rule!Tasr_startDateValidation(ri!Tasr_Requests.startDate) ), a!dateField( label: "End Date", labelPosition: "JUSTIFIED", value: ri!Tasr_Requests.endDate, saveInto: { a!save(local!data.endDate, save!value), a!save(ri!Tasr_Requests.endDate, save!value) }, required: true, requiredMessage: "End Date is Required", validations: rule!Tasr_endDateValidation( ri!Tasr_Requests.startDate, ri!Tasr_Requests.endDate ) ) } ), a!columnLayout( contents: { a!textField( label: "Requested By:", labelPosition: "JUSTIFIED", value: rule!GBL_displayUserFirstLast(loggedInUser()), saveInto: ri!Tasr_Requests.requestorName, readOnly: true() ), a!textField( label: "Requestor Email:", labelPosition: "JUSTIFIED", value: loggedInUser(), saveInto: ri!Tasr_Requests.requestorEmail, readOnly: true(), validations: {} ), a!dateTimeField( label: "Requested On:", labelPosition: "JUSTIFIED", value: now(), saveInto: ri!Tasr_Requests.createdOn, readOnly: true(), validations: {} ) } ) } ), a!paragraphField( label: "Email Addresses", labelPosition: "JUSTIFIED", placeholder: "Email Addresses should be one per line (can be pasted from Excel)", value: local!data.emailAddresses, saveInto: { a!save(local!data.emailAddresses, save!value), a!save( ri!Tasr_Requests.emailAddresses, save!value) }, refreshAfter: "KEYPRESS", height: "TALL", required: true, requiredMessage: "Email Address is Required", validations:if( (a!isNotNullOrEmpty(local!invalidEmails)), "Emails must be in a valid format, and each email must be on a new line. ", {} ) ), a!cardLayout( contents: { /*a!richTextDisplayField(*/ /*labelPosition: "COLLAPSED",*/ /*value: {*/ /*a!richTextIcon(*/ /*icon: "info-circle",*/ /*caption:"",*/ /*color: "#0000ff",*/ /*size: "MEDIUM"*/ /*),*/ a!textField( label: "error", value: ri!InvalidEmail, ) }, align: "CENTER", showWhen: ri!HasError=true(), style: "INFO", marginAbove: "NONE", marginBelow: "LESS", accessibilityText: "Information message" ), }, style: "#134f5c", marginBelow: "STANDARD" ) } ) } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget_23r3( label: "Submit", style: "PRIMARY", submit: true, validate: true(), saveInto: { a!save(ri!TASR_Requests.emailAddresses,local!formattedEmailString), a!startProcess( processmodel:cons!Tasr_WRITE_REQUESTS, processParameters: { Emails:local!formattedEmailString }, ), a!save( ri!Tasr_Requests.requestorName, rule!GBL_displayUserFirstLast(loggedInUser()) ), a!save( ri!Tasr_Requests.requestorEmail, loggedInUser() ), a!save(ri!Tasr_Requests.createdOn, now()), a!save( ri!Tasr_Requests.requestStatus, cons!Tasr_AUDIT_STATUS_TYPES[1] ), a!save( ri!Tasr_Requests.requestType, cons!Tasr_REQUEST_TYPE ), a!save(ri!Tasr_Requests.isActive, true()), /*a!save(ri!Tasr_Requests.employeeIDs,index(ri!Result.body,"values",null()))*/ }, loadingIndicator: true() ) }, secondaryButtons: { a!buttonWidget_23r3( label: "Cancel", style: "NORMAL", submit: true, validate: false, value: true, saveInto: ri!cancel ) } ) ) )
If i create expressionrule then we would need data to be stored but as per the requirement it shold be stored only when there is no invalid emails . if any invalid emails then again show it on UI (3rd Xor)
ZAINAB said:If i create expressionrule then we would need data to be stored but as per the requirement it shold be stored only when there is no invalid emails
I'm not sure what you mean. An expression rule doesn't "store" anything that the process instance isn't already storing. Your expression rule should mirror (almost exactly) the code in your script task (only) and accept the email list and the JSON list as inputs, and should output only your "invalid email address".
For expression rule ,doesn't it required to call data from DB ?please let me know how can I create expressionrule and how to pass those process variable
ZAINAB said:For expression rule ,doesn't it required to call data from DB ?
Absolutely not - expression rules can handle any arbitrary input data, almost exactly like a script task in a process model would (but much easier to edit and test). You would just pass in your PV data and have it do whatever complex processing you need, and save the output to a PV (just like you do in your script task).
Have you taken the online Appian training? Knowing how to use expression rules is ABSOLUTELY CRITICAL in effective Appian development.
ZAINAB said:how can I create expressionrule
various ways - the "official" way is you go to your application object and click "create" -> "expression rule". However for quick testing you can create a new/unsaved expression rule simply by going to "yourenvironmenturl.com/suite/design/rule", which will load the (blank) expression rule editor.
I got the issue , i guess in EmailPV it is passing all emailaddress as one string that's the reason we are getting all the valid & invalid adress in outputPlease suggest how to pass emailaddress seperately as each string