Hey, I’m pretty new to corteza and I like it very much. Now I’m a bit stuck with workflows, specifically on how to Update System User information. Here’s my situation:
- I have a module “accounts” in my namespace “test”. It looks like this:
My goal is to manage a number of members in this module with additional information (addresses, billing information,…). These members have access to corteza (log in) and are able to access some sort of “self-service-portal” (Basically some pages where they can list some records and edit them)
So i need to create a user for every record of this member module. My idea was a workflow that creates a user using the onBeforeCreate/onBeforeUpdate triggers. The creation of this user works flawlessly. When the user is created, the new user is set in the user field of the member record (linking). Editing the member record and then updating the Name and Email of the System User does not work. The User update function always throws the error “invalid ID”. Heres my workflow (screenshot):
https://imgur.com/a/BbZMfbV
And heres the code:
{
"workflows": [
{
"handle": "",
"enabled": true,
"meta": {
"name": "User update and creation",
"description": "",
"visual": null
},
"keepSessions": 0,
"steps": [
{
"stepID": "4",
"kind": "expressions",
"ref": "",
"arguments": [
{
"target": "record.values.fullName",
"expr": "record.values.firstName + \" \" + record.values.lastName",
"type": "String"
}
],
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": false,
"id": "4",
"parent": "1",
"value": "Update Record",
"xywh": [
2440,
1960,
200,
80
]
}
}
},
{
"stepID": "6",
"kind": "gateway",
"ref": "excl",
"arguments": null,
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "6",
"parent": "1",
"value": "Exclusive",
"xywh": [
2688,
2040,
200,
80
]
}
}
},
{
"stepID": "9",
"kind": "function",
"ref": "usersCreate",
"arguments": [
{
"target": "user",
"expr": "{\n \"email\": record.values.email,\n \"name\": record.values.fullName\n}",
"type": "User"
}
],
"results": [
{
"target": "newUser",
"expr": "user",
"type": "User"
}
],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "9",
"parent": "1",
"value": "User create",
"xywh": [
2288,
2072,
200,
80
]
}
}
},
{
"stepID": "10",
"kind": "expressions",
"ref": "",
"arguments": [
{
"target": "record.values.user",
"expr": "newUser",
"type": "User"
}
],
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": false,
"id": "10",
"parent": "1",
"value": "Link User <-> Member",
"xywh": [
2264,
2224,
200,
80
]
}
}
},
{
"stepID": "16",
"kind": "function",
"ref": "usersUpdate",
"arguments": [
{
"target": "user",
"expr": "{\n \"ID\": record.values.user,\n \"email\": record.values.email,\n \"name\": record.values.fullName\n}",
"type": "User"
}
],
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "16",
"parent": "1",
"value": "User update",
"xywh": [
2672,
2240,
200,
80
]
}
}
},
{
"stepID": "21",
"kind": "termination",
"ref": "",
"arguments": null,
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "21",
"parent": "1",
"value": "Terminate workflow execution",
"xywh": [
2656,
2448,
200,
80
]
}
}
}
],
"paths": [
{
"expr": "false",
"parentID": "6",
"childID": "9",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "13",
"parent": "1",
"points": [],
"style": "exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.25;entryDx=0;entryDy=0;",
"value": "If No User"
}
}
},
{
"parentID": "9",
"childID": "10",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "14",
"parent": "1",
"points": [],
"style": "exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=0.25;entryY=0;entryDx=0;entryDy=0;",
"value": null
}
}
},
{
"expr": "true",
"parentID": "6",
"childID": "16",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "17",
"parent": "1",
"points": [],
"style": "exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;",
"value": "#2 - Else (if)"
}
}
},
{
"parentID": "10",
"childID": "21",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "22",
"parent": "1",
"points": [],
"style": "exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;",
"value": null
}
}
},
{
"parentID": "16",
"childID": "21",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "23",
"parent": "1",
"points": [],
"style": "exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.25;entryY=0;entryDx=0;entryDy=0;",
"value": null
}
}
},
{
"parentID": "4",
"childID": "6",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "29",
"parent": "1",
"points": [],
"style": "exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;",
"value": null
}
}
}
],
"triggers": [
{
"resourceType": "compose:record",
"eventType": "beforeUpdate",
"constraints": [
{
"name": "namespace.handle",
"op": "=",
"values": [
"test"
]
},
{
"name": "module.handle",
"op": "=",
"values": [
"accounts"
]
}
],
"enabled": true,
"stepID": "4",
"meta": {
"description": "",
"visual": {
"defaultName": true,
"edges": [
{
"childID": "4",
"meta": {
"description": "",
"label": "",
"visual": {
"id": "33",
"parent": "1",
"points": [],
"style": "exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;",
"value": null
}
},
"parentID": "3"
}
],
"id": "3",
"parent": "1",
"value": "Compose record - beforeUpdate",
"xywh": [
2080,
1912,
200,
80
]
}
}
}
]
}
]
}