a!localVariables( local!allRole:rule!KONE_Development_ROLE(), local!allLanguage:rule!KONE_Development_LANGUAGE(), local!allBranch:rule!KONE_Development_BRANCH(), local!allRegion:rule!KONE_Development_REGION(), a!formLayout( contents: { a!textField( label: "Username", value: {ri!userinputsheet.kone_user_name}, saveInto: {ri!userinputsheet.kone_user_name, a!save(ri!userrole.NAME,ri!userinputsheet.kone_user_name) }, required: true ), a!textField( label: "firstName", value: {ri!userinputsheet.FIRST_NAME}, saveInto: {ri!userinputsheet.FIRST_NAME}, required: true ), a!textField( label: "LastName", value: {ri!userinputsheet.LAST_NAME}, saveInto: {ri!userinputsheet.LAST_NAME}, required: true ), a!textField( label: "Email", value: {ri!userinputsheet.Email}, saveInto: { a!save(ri!userinputsheet.Email,ri!userinputsheet.Email), a!save(ri!userrole.EMAIL,ri!userinputsheet.Email) }, required: true ), a!dropdownField( label:"Role", placeholder:"---please fill your Role---", choiceLabels:reject(fn!isnull,local!allRole), choiceValues:reject(fn!isnull,local!allRole), value:ri!userinputsheet.Role, saveInto:{ a!save(ri!userinputsheet.Role,ri!userinputsheet.Role), a!save(ri!userrole.ROLE_ID, a!forEach (items:rule!KONE_Development_Role_RoleId, expression:if(fv!item.Role=ri!userinputsheet.Role,fv!item.Role_Id,{}) )), a!save(ri!userrole.PHASE_ID, a!forEach (items:rule!KONE_Development_Role_RoleId, expression:if(fv!item.Role=ri!userinputsheet.Role,fv!item.Role_Id,{}) )) }, required:true ), a!dropdownField( label:"Branch", placeholder:"---please fill your Branch---", choiceLabels:reject(fn!isnull,local!allBranch), choiceValues:reject(fn!isnull,local!allBranch), value:ri!userinputsheet.Branch, saveInto:{ a!save(ri!userinputsheet.Branch,ri!userinputsheet.Branch), a!save(ri!userrole.BRANCH,ri!userinputsheet.Branch), a!save(ri!userrole.BRANCH_ID, a!forEach (items:rule!KONE_Development_Branch_BranchId, expression:if(fv!item.Branch=ri!userinputsheet.Branch,fv!item.Branch_Id,{}) )) }, required:true ), a!dropdownField( label:"Region", placeholder:"---please fill your Region---", choiceLabels:reject(fn!isnull,local!allRegion), choiceValues:reject(fn!isnull,local!allRegion), value:ri!userinputsheet.Region, saveInto:{ a!save(ri!userinputsheet.Region,ri!userinputsheet.Region), a!save(ri!userrole.REGION,ri!userinputsheet.Region), a!save(ri!userrole.REGION_ID, a!forEach (items:rule!KONE_Development_Region_RegionId, expression:if(fv!item.Region=ri!userinputsheet.Region,fv!item.Region_Id,{}) )) }, required:true ), a!textField( label: "ManagerRole", value: {ri!userinputsheet.Manager_role}, saveInto: { a!save(ri!userinputsheet.Role,ri!userinputsheet.Role), a!save(ri!userrole.ROLE,ri!userinputsheet.Role)}, required: true ), a!dropdownField( label:"Language", placeholder:"---please fill your Language---", choiceLabels:reject(fn!isnull,local!allLanguage), choiceValues:reject(fn!isnull,local!allLanguage), value:ri!userinputsheet.Language, saveInto:{ri!userinputsheet.Language, a!save(ri!userrole.LANGUAGE_ID, a!forEach (items:rule!KONE_Development_Role_RoleId, expression:if(fv!item.Language=ri!userinputsheet.Language,fv!item.Language_Id,{}) )) }, required:true ), a!textField( label: "CELevel", value: {ri!userinputsheet.CE_LEVEL}, saveInto: { a!save(ri!userinputsheet.CE_LEVEL,ri!userinputsheet.CE_LEVEL), a!save(ri!userrole.LEVEL,ri!userinputsheet.CE_LEVEL) }, required: true ), a!textField( label: "Telephone Number", value: {ri!userinputsheet.Telephone_number}, saveInto: { a!save(ri!userinputsheet.Telephone_number,ri!userinputsheet.Telephone_number), a!save(ri!userrole.TELEPHONE_NUMBER,ri!userinputsheet.Telephone_number) }, required: true ), a!textField( label: "Exceptional Case Library View Right", value: {ri!userinputsheet.Exceptional_case_library_view_right}, saveInto: { a!save(ri!userinputsheet.Exceptional_case_library_view_right,ri!userinputsheet.Exceptional_case_library_view_right), a!save(ri!userrole.IS_EXCEPTION,ri!userinputsheet.Exceptional_case_library_view_right) }, required: true ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Submit", saveInto:( a!writeToDataStoreEntity( dataStoreEntity: {cons!KONE_Development_userinputsheet_Constant,cons!KONE_Development_userrole_Constant}, valueToStore:{ri!userinputsheet,ri!userrole } ), ), submit: true, style: "PRIMARY" ) } ) ) )
I am trying to find the roleId by join the save role between two tables and save it into database, i used a!forEach loops for keep searching the equal role, but seems it is not acceptable and can't find fv!index seemly. Error report as follow:
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error [evaluation ID = 88465:3ed58] : An error occurred while executing a save: Expression evaluation error at function a!forEach [line 52]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index: Cannot index property 'Role' of type Text into type Rule or Function Reference
Discussion posts and replies are publicly visible
your a!forEach items are: "rule!KONE_Development_Role_RoleId" (no ->()? ) in your expression you are searching within the values you inserting with this rule for the attribure "role" for each item.1.) check the format of "KONE_Development_Role_RoleId". Does it have an attribute role_id?2.) perhaps insert KONE_Development_Role_RoleId into a local and use the local. so you have more control what kind of values you are inserting in that array via your rule
i forgot that parenthesis
do you know why my drop box just appear the value for 1 seconds? Then it appear back to placeholder
a!save(ri!userinputsheet.Role,ri!userinputsheet.Role), ->you are saving the value into itself.
suggestion:
a!save( target: ri!userinputsheet.Role, value: save!value )
save!value refer to what?
the value you write/chooe in your sail form component. in general you need to save your written text/number or selected value like a date etc
usually done by this:
EXAMPLES: value: local!myVariable, /*or ri!myVariable*/ saveInto:{ local!myVariable, /*or into a ruleinput like ri!myVariable*/ a!save(), a!save() }, Or value: local!myVariable, /*or ri!myVariable*/ saveInto:{ a!save( target: local!myVariable, value: save!value ), a!save(), a!save() },
Thank you sir, do you know how to make the active column of database be allowed to be null from database?
can you elaborate? I didn't really get your issue,
sometime the back end database certain column can't be null, in the interface i didn't require user fill it, however i don't want this those column can't leave empty in the back end report any error, what I did is fill in some default value, and then it didn't report any error, now would be fine. But i wonder are there any better ways jump over it besides fill in some default value.