I’m trying to get it so that a customer can submit a company name as their user group.
When the customer attempts to create an account I’d like to allow them to enter a company name.
I will then use a workflow to check to see if that group is already created.
If yes, I will send an email to the admin requesting access for the new user.
If no, I will create the the new user group and assign the creator as the administrator.
I am getting stuck on how best to submit the userTags data back to Losant using HTML.
I see the schema for a new experience user (and know that I’m going to need to make the post request match parts of this to create the user appropriately):
I would suspect the Validation Payload Schema for userTags to look something like this:
"userTags": {
"group": {
"type":"string"
}
}
I try to format similarly to how it would be output on the payload. I know that group has to be a key for userTags based on the payload shown here:
One thing I am not certain of is naming conventions for userTags within the component. It could be that id and name should be group (thinking out loud here), but I am curious to see the output you get from the Validate Payload Node. Let me know what comes back and we will take the next steps to debugging this!
Here is the error which is generated after we attempt to create the new user (which is to say that we made it past the initial validation node but when we submit the request to create the user it doesn’t like the format that we submit the userTags in… which seems to be because the userTags should be an object with a “key” (group): “value” (company name) pair. I’m not sure how to send an object back using the HTML form submission (which is written in the profileForm) instead of a string which is what we are sending back now. Or should this be handled on the workflow side, perhaps utilizing a mutate node before submitting to the Create User Node?
I built out a similar example and was able to recreate this problem. After a bit of research, I discovered a Stack Overflow post with the answer:
“HTML provides no way to generate JSON from form data.”
Thus, if you would like to handle the form data client-side, you will have to use Javascript, and these answers have some suggestions on how to do so. If you would like to do this in the workflow, you would need only add a Mutate node:
To complete this thread, is there a way to assign a group to a user from a workflow?
In my case, a user from an existing company (group) signs up and enters a company code. This company code is registered under a group (company) and I use a data table to store my companies and company codes.
When a user submits a company code, the group name is pulled from the data table, and this name is used to get the group.
Here is my group in my payload:
Now, I can’t manage to assign this group to the user from the workflow, using the “User: Update” node:
Note that I’ve tried {{data.group.id}} and {{data.group.name}} without success.
Any tips?
And here’s my User Group configuration in my User: Update Node:
How are you referencing the user you are trying to update the group for? Via email or with the user ID that’s provided in the Experience Context? For example, I am just updating the group for 1 user:
When your experience workflow runs, is the user being removed from all groups? Or, is the group just not updating to what you would like it to be?
How are you getting the group ID for the group you would like the user to be moved to?
As always, you can right click a payload path and copy the path:
Don’t forget you can test templates in the workflow engine with the Payload Tester:
And you can always copy the whole payload to clipboard, and test it in the Template Tester in our documentation.