Click HERE to see how Saviynt Intelligence is transforming the industry. |
01/30/2024 05:43 AM
I am hoping that someone can point me to the simple mistake I'm making because this has been driving me nuts for a week now.
Here is the error message I get when trying to create the account. The account task is generated from a technical rule (arstasksObj.source = "ZERODAY"). From what I can tell the syntax for the json is correct but that because the requestAccessAttributes binding variable is {} (ie null) then its throwing off my if statement. If I generate an ARS request task (arstasksObj.source = "REQUEST") then the first section of code in the create account json works just fine without any errors.
"2024-01-29T21:07:37.470+00:00","ecm-worker","ldap.SaviyntGroovyLdapService","quartzScheduler_Worker-4-vnxm5","ERROR","Error while creating account 123456 in AD - Error parsing JSON"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5","","org.codehaus.groovy.grails.web.converters.exceptions.ConverterException: Error parsing JSON at grails.converters.JSON.parse(JSON.java:292) at com.saviynt.ldap.SaviyntGroovyLdapService$_createAccountGLDAP_closure2.doCall(SaviyntGroovyLdapService.groovy:598) at com.saviynt.ldap.SaviyntGroovyLdapService.createAccountGLDAP(SaviyntGroovyLdapService.groovy:245) at com.saviynt.ecm.services.ArsTaskService.createAccountTarget(ArsTaskService.groovy:11680) at com.saviynt.ecm.services.ArsTaskHelperService$_whenTaskTypeIsThreeNewAccountAccess_closure50.doCall(ArsTaskHelperService.groovy:3075) at com.saviynt.ecm.services.ArsTaskHelperService.whenTaskTypeIsThreeNewAccountAccess(ArsTaskHelperService.groovy:3066) at com.saviynt.ecm.services.ArsTaskHelperService$_completeAutoProvTasksUpgraded_closure1.doCall(ArsTaskHelperService.groovy:175) at com.saviynt.ecm.services.ArsTaskHelperService.completeAutoProvTasksUpgraded(ArsTaskHelperService.groovy:160) at MultipleProvisioningJob.execute(MultipleProvisioningJob.groovy:222) at org.quartz.core.JobRunShell.run(JobRunShell.java:199) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)Caused by: org.codehaus.groovy.grails.web.json.JSONException: Expected a ':' after a key at character 7 of {null"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5","","}"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5",""," at grails.converters.JSON.parse(JSON.java:283)"
"2024-01-29T21:07:37.581+00:00","ecm-worker","","null-vnxm5",""," ... 10 more"
Please note that I have shorted the attached json code and removed sensitive stuff. The instance version is 23.11
Solved! Go to Solution.
01/30/2024 06:34 AM - edited 01/30/2024 07:00 AM
Hi @igorvt77 ,
Use if-else to check the source of the task, if source is Request then only use requestAccessAttributes otherwise not. You can use below expression to check the source of the task.
${arstasksObj?.source.equalsIgnoreCase('REQUEST')}
01/30/2024 06:37 AM
${arstasksObj?.source?.equalsIgnoreCase('REQUEST')}
01/30/2024 07:02 AM
I actually tried ${arstasksObj?.source != 'ZERODAY'} but it didn't seem to work. Any reason why you must use the format you provided ?
Also do you know if you can nest the if statements ?
Example:
{${if(arstasksObj.source?.equalsIgnoreCase('REQUEST'))
if(requestAccessAttributes?.get('objecttype') == 'AdminAccount')
....
else
....
01/30/2024 07:07 AM
Update: I tried the provided solution above and I'm still receiving the same parsing json error.
02/14/2024 08:38 AM
In case anyone had seen this and was trying to do something similar, the code I had was fine and apparently the error was coming from the code I was using in my CHECKFORUNIQUE json which was trying to access a binding variable that was not supported. Once I removed that then everything worked fine.
02/14/2024 10:23 AM
/what was that variable ?
02/14/2024 10:35 AM
I believe it was the "requestAccessAttributes" but hard to know for sure. Here is what I had:
{${ if (requestAccessAttributes?.get('objecttype') == 'AdminAccount')
' "sAMAccountName": "' + arstasksObj?.accountName + '" '
else if ((arstasksObj?.accountKey?.accounttype == 'Employee') || (arstasksObj?.accountKey?.accounttype == 'NonEmployee'))
' "sAMAccountName": "' + user.username + '" '
}
}