I tried to implement a workflow which needs the current user data object. Unfortunately, the documentation is not detailed enough to describe a simple funtion/workflow to retrieve the current user data object.
Achieved this by updating a data record and retrieving the user from the UpdatedBy field.
What a smart workaround!
I am coming to this subject after one year. Is there a better way to do it with the version 2022.9.2 ?
Is there any way to do it without modifying the record ?
With the some events like âonManualâ, the variable âinvokerâ seems to be type âauth.identityâ. Is there any way to get the user from it ?
Thank you very much for your help guys !
You can use the invoker variable which hold the UserID of the User to get the User Details using âUser Lookupâ function in workflow.
Hi guys,
maybe someone can explain how you configured your function?
Iâve also configured a user lookup function with Arguments:
lookup* (ID):
value: invoker (Expression enabled)
target: agent
On testing my workflow, I receive an error:
Test failed: workflow 269709671613333506 step 29 execution failed: cannot cast value *auth.identity to ID (target lookup): unable to create ID: unable to cast auth.identity{id:0x326418c09000003, memberOf:[]uint64{0x3879c0a77000003, 0x3879c0a6c010003}} of type auth.identity to uint64
If Iâm changing the value to a static userid ââ (recieved from cli: corteza-server users list) the Workflow works successfully.
Iâve also converted the invoker value with Expressions into ID and also tested conversion to uint but both ways doesnât work.
many thanks in advance.
Pascal
Hi,
No, at the moment not.
One note: the running user ID might be different than the ID of the person that triggered the workflow, because the workflow can be ârun asâ.
Aa, I didnât know about this invoker variable. That should work then.
Iâve encountered the same error before, and to fix it, I used a block to create and modify variables. I stored the âinvokerâ variable in another variable of string type, naming it âVarID1â; then, I assigned the âVarID1â variable to a second variable I created of ID type, named âVarID2â.
Next, I took this âVarID2â variable and used it to perform the user lookup, like this:
User Lookup Block:
lookup*: (ID) VarID2
It worked for me.
`{
"workflows": [
{
"handle": "",
"enabled": true,
"meta": {
"name": "Teste Invoker",
"description": "",
"visual": null
},
"keepSessions": 0,
"steps": [
{
"stepID": "6",
"kind": "function",
"ref": "usersLookup",
"arguments": [
{
"target": "lookup",
"expr": "VarID2",
"type": "ID"
}
],
"results": [
{
"target": "VarUser",
"expr": "user",
"type": "User"
}
],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "6",
"parent": "1",
"value": "User lookup",
"xywh": [
2880,
2000,
200,
80
]
}
}
},
{
"stepID": "8",
"kind": "expressions",
"ref": "",
"arguments": [
{
"target": "VarID1",
"expr": "invoker",
"type": "String"
}
],
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "8",
"parent": "1",
"value": "Define and mutate scope variables",
"xywh": [
2320,
2000,
200,
80
]
}
}
},
{
"stepID": "12",
"kind": "expressions",
"ref": "",
"arguments": [
{
"target": "VarID2",
"expr": "VarID1",
"type": "ID"
}
],
"results": [],
"meta": {
"name": "",
"description": "",
"visual": {
"defaultName": true,
"id": "12",
"parent": "1",
"value": "Define and mutate scope variables",
"xywh": [
2600,
2000,
200,
80
]
}
}
}
],
"paths": [
{
"parentID": "8",
"childID": "12",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "10",
"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": "12",
"childID": "6",
"meta": {
"name": "",
"description": "",
"visual": {
"id": "15",
"parent": "1",
"points": [],
"style": "exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;",
"value": null
}
}
}
],
"triggers": [
{
"resourceType": "compose:record",
"eventType": "onManual",
"constraints": [
{
"name": "namespace.handle",
"op": "=",
"values": [
"Workspace"
]
},
{
"name": "module.handle",
"op": "=",
"values": [
"ControleReajuste-CR"
]
}
],
"enabled": true,
"stepID": "8",
"meta": {
"description": "",
"visual": {
"defaultName": true,
"edges": [
{
"childID": "8",
"meta": {
"description": "",
"label": "",
"visual": {
"id": "14",
"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": "4"
}
],
"id": "4",
"parent": "1",
"value": "Compose record - onManual",
"xywh": [
2040,
2000,
200,
80
]
}
}
}
]
}
]
}`