Update User Status from System template
- Muhammad_MoizOP 1
I am trying to update user record from System template, what I want is first retrieved the old record and archived the current User contract and create new one with updated status and every thing remain same.
here is my sample templatetemplate SystemUser with name : Text user : Party where signatory user// This choice will update User status
-{ choice UpdateStatus : ContractId User -}type UserKey = (Party, Int)template User with profileId : Int code : Optional Text name : Optional Text email: Optional Text status : Text user : Party systemUser : Party where signatory [systemUser , user] key ( user, profileId ) : Userkey maintainer key._1 - SamirTalwar 2
Hey @Muhammad_Moiz. Could you show us the choice you wrote and what the problem is? Any error messages or unexpected behavior would be helpful.
Without some idea of where it’s going wrong, it’s very hard to know how to help.
- Muhammad_Moiz 1
This is my sample code to update status from SystemUser template but it show me error on “this” key word
Couldn’t match type ‘SystemUser’ with ‘User’
Expected type: Update (ContractId User)
Actual type: Update (ContractId SystemUser)choice UpdateStatus : ContractId User controller user do create this with status = if status == "Active" then "Archived" else "Active" - Leonid_Rozenberg 1
Within the body of a template
thisrefers to an instance of that template. In your case you are writing the choiceUpdateStatusinside the body of aSystemUsertemplate (which you can see from the “Actual type: …” error message), but the returned element of that choice is aUser.If you leave this choice within the SystemUser template, you need to pass in a
ContractId Useras an argument to that the choice:choice UpdateStatus : ContractId User with userContractChangeId: ContractId User user : Party controller user do userContract <- fetch userContractToChangeId create userContract with status = if status == "Active" then "Archived" else "Active"