Click HERE to see how Saviynt Intelligence is transforming the industry. |
08/27/2024 03:59 AM - edited 08/27/2024 06:57 AM
Dear All,
As Saviynt is not able to send an e-mail to a list of people without triggering an approval ... I've decided ti create a class in java that will do that workflow action.
Question is:
1- How can I get the body template via code from my existing templates?
2- Is there any place where we have java Jar working examples? I've seen in many posts some code here and there but nowhere any clear example end-to-end.
3- Is there any official documentation on the available java classes and functions that we can use from within the Saviynt product or we need to rise a ticket every time that we have any specific request?
4- If I cannot call directly the sendmail function from jar and I need to call the rest endpoint how do i get current sav url, token and all other needed parameters?
Kind regards,
Albert.
Solved! Go to Solution.
08/27/2024 08:29 AM
1- How can I get the body template via code from my existing templates?
2- Is there any place where we have java Jar working examples? I've seen in many posts some code here and there but nowhere any clear example end-to-end.
No there is no example, Create simple java program and load jar and restart application
3- Is there any official documentation on the available java classes and functions that we can use from within the Saviynt product or we need to rise a ticket every time that we have any specific request? You can use any java functions supported in jdk 1.8
4- If I cannot call directly the sendmail function from jar and I need to call the rest endpoint how do i get current sav url, token and all other needed parameters? - Its supported
08/29/2024 07:52 AM
Hello @rushikeshvartak ,
Ok, I managed to get a class workking but now I need to send the Map paramter that the workflow is expecting as parameters
Error:
"org.jbpm.pvm.internal.wire.WireException: method sendEmail('arg':'test')(java.util.HashMap)
What is the right format so it's accepted by Sav as paramter? If I don't put anything it works fine but I need the parameter to send the e-mail to that person.
Kind regards,
Albert.
08/29/2024 08:17 AM
Share code to suggest changes.
08/29/2024 08:33 AM
All tests just to see that it executes the right method ... I don't mind to pass all as a Sing or whatever I'll do the split later on if needed.
08/29/2024 08:36 AM
public static void sendEmail(Object obj) throws Exception {
Logger logger = Logger.getLogger(MyAccessUtils.class.getName());
logger.info("[MyAccessUtils] sendEmail(Object obj)!");
Map<String, String> jobInputs;
if (obj instanceof Map) {
jobInputs = (Map<String, String>) obj;
} else {
throw new IllegalArgumentException("Expected a Map<String, String> as input");
}
// Proceed with sending the email
executeProcess(jobInputs);
logger.info("[MyAccessUtils] sendEmail(Object obj) => FINISHED");
}
08/29/2024 08:53 AM
I'll test now what you sent me. I've also tested with the next parameters --> {"A":"B"} and I'm getting below error which is strange because map is declared.
"2024-08-29T15:44:25.731+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-4-vlcdq","DEBUG","Lets Invoke Class Namecom.myaccess.MyAccessUtils method sendEMail"
"2024-08-29T15:44:25.732+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-4-vlcdq","DEBUG","arguments: {"A":"B"}"
"2024-08-29T15:44:25.732+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-4-vlcdq","DEBUG","argumentsMap:[A:B]"
"2024-08-29T15:44:25.733+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-4-vlcdq","ERROR","Error: "
"2024-08-29T15:44:26.106+00:00","ecm-worker","","null-vlcdq","","java.lang.NoSuchMethodException: com.myaccess.MyAccessUtils.sendEMail(java.util.Map) at java.lang.Class.getMethod(Class.java:1814) at ExternalJarJob.execute(ExternalJarJob.groovy:87) at org.quartz.core.JobRunShell.run(JobRunShell.java:199) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)"
08/29/2024 09:07 AM
hello @rushikeshvartak ,
Same error as before with the new method:
"2024-08-29T16:04:25.104+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-10-pv5dt","DEBUG","START ExternalJarJob"
"2024-08-29T16:04:25.120+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-2-pv5dt","DEBUG","START ExternalJarJob"
"2024-08-29T16:04:25.139+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-10-pv5dt","DEBUG","Lets Invoke Class Namecom.myaccess.MyAccessUtils method sendEMail"
"2024-08-29T16:04:25.139+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-2-pv5dt","DEBUG","Lets Invoke Class Namecom.myaccess.MyAccessUtils method sendEMail"
"2024-08-29T16:04:25.144+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-10-pv5dt","DEBUG","arguments: {"A":"B"}"
"2024-08-29T16:04:25.144+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-2-pv5dt","DEBUG","arguments: {"A":"B"}"
"2024-08-29T16:04:25.150+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-10-pv5dt","DEBUG","argumentsMap:[A:B]"
"2024-08-29T16:04:25.150+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-2-pv5dt","DEBUG","argumentsMap:[A:B]"
"2024-08-29T16:04:25.151+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-10-pv5dt","ERROR","Error: "
"2024-08-29T16:04:25.421+00:00","ecm-worker","","null-pv5dt","","java.lang.NoSuchMethodException: com.myaccess.MyAccessUtils.sendEMail(java.util.Map) at java.lang.Class.getMethod(Class.java:1814) at ExternalJarJob.execute(ExternalJarJob.groovy:87) at org.quartz.core.JobRunShell.run(JobRunShell.java:199) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)"
"2024-08-29T16:04:25.151+00:00","ecm-worker","jobs.ExternalJarJob","quartzScheduler_Worker-2-pv5dt","ERROR","Error: "
"2024-08-29T16:04:25.421+00:00","ecm-worker","","null-pv5dt","","java.lang.NoSuchMethodException: com.myaccess.MyAccessUtils.sendEMail(java.util.Map) at java.lang.Class.getMethod(Class.java:1814) at ExternalJarJob.execute(ExternalJarJob.groovy:87) at org.quartz.core.JobRunShell.run(JobRunShell.java:199) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)"
Kind regards,
Albert.
08/29/2024 09:23 AM
Hi @travemole , try giving the argument in double quotes ..
So currently the Java code is not able to read the input too?
08/29/2024 09:33 AM - edited 08/29/2024 09:38 AM
Hi @NM ,
I've managed to make it work in the jobs using a deprecated method and now I'm trying to figure out the right way of writing it in the workflows. NOTE: Workflows do not accept as parameter the " so you can only use single ' or maybe \". I'm testing all possibilities now... It would be GREAT to have this kind of things documented as I've seen a LOT of posts asking for the same but no clear answer in any of them.
My current error is:
"2024-08-29T16:29:56.250+00:00","ecm","services.WorkflowService","http-nio-8080-exec-8-nj4vq","ERROR","Exception in workflow service"
"2024-08-29T16:29:56.282+00:00","ecm","","null-nj4vq","","org.jbpm.pvm.internal.wire.WireException: method sendEmail({'A':'B'})(java.util.HashMap) is not available on object com.myaccess.MyAccessUtils@50c9a017 (com.myaccess.MyAccessUtils) at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.invokeMethod(ObjectDescriptor.java:202) at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.java:76) at org.jbpm.jpdl.internal.activity.JpdlAutomaticActivity.execute(JpdlAutomaticActivity.java:15) at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:672) at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:582) at org.jbpm.pvm.internal.model.ExecutionImpl.take(ExecutionImpl.java:487) at org.jbpm.jpdl.internal.activity.ForEachActivity.execute(ForEachActivity.java:123) at org.jbpm.jpdl.internal.activity.ForEachActivity.execute(ForEachActivity.java:53) at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:672) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:632) at org.jbpm.pvm.internal.model.ExecutionImpl.start(ExecutionImpl.java:217) at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:63) at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:36) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45) at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56) at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.startProcessInstanceByKey(ExecutionServiceImpl.java:71) at com.saviynt.ecm.services.WorkflowService.workflowaccessreqStart(WorkflowService.groovy:1070) at com.saviynt.ws.JbpmapiService.workflowaccessreqStartMS(JbpmapiService.groovy:64) at com.saviynt.ecm.ws.JbpmapiController$_closure4.doCall(JbpmapiController.groovy:61) at grails.plugin.springsecurity.rest.RestTokenValidationFilter.processFilterChain(RestTokenValidationFilter.groovy:118) at grails.plugin.springsecurity.rest.RestTokenValidationFilter.doFilter(RestTokenValidationFilter.groovy:84) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at com.saviynt.webservice.SaviyntRestAuthenticationFilter.doFilter(SaviyntRestAuthenticationFilter.groovy:158) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62) at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.java:59) at com.mrhaki.grails.plugin.xframeoptions.web.XFrameOptionsFilter.doFilterInternal(XFrameOptionsFilter.java:69) at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:82) at java.lang.Thread.run(Thread.java:750)"
If you know the answer please do not hesitate to say it ... as It's very painful to test.
08/29/2024 09:50 AM
Did you tested with string as input ?
08/29/2024 10:11 AM
Same thing ... not sure anymore if it's even possible as I've tried all possible combinations.
"2024-08-29T17:10:01.282+00:00","ecm","","null-nj4vq","","org.jbpm.pvm.internal.wire.WireException: method sendEmail('test')(java.util.HashMap) is not available on object com.myaccess.MyAccessUtils@42d54f9 (com.myaccess.MyAccessUtils) at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.invokeMethod(ObjectDescriptor.java:202) at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.java:76) at org.jbpm.jpdl.internal.activity.JpdlAutomaticActivity.execute(JpdlAutomaticActivity.java:15) at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:672) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:632) at org.jbpm.pvm.internal.model.ExecutionImpl.start(ExecutionImpl.java:217) at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:63) at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:36) at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42) at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45) at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53) at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40) at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56) at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.startProcessInstanceByKey(ExecutionServiceImpl.java:71) at com.saviynt.ecm.services.WorkflowService.workflowaccessreqStart(WorkflowService.groovy:1070) at com.saviynt.ws.JbpmapiService.workflowaccessreqStartMS(JbpmapiService.groovy:64) at com.saviynt.ecm.ws.JbpmapiController$_closure4.doCall(JbpmapiController.groovy:61) at grails.plugin.springsecurity.rest.RestTokenValidationFilter.processFilterChain(RestTokenValidationFilter.groovy:118) at grails.plugin.springsecurity.rest.RestTokenValidationFilter.doFilter(RestTokenValidationFilter.groovy:84) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at com.saviynt.webservice.SaviyntRestAuthenticationFilter.doFilter(SaviyntRestAuthenticationFilter.groovy:158) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62) at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.java:59) at com.mrhaki.grails.plugin.xframeoptions.web.XFrameOptionsFilter.doFilterInternal(XFrameOptionsFilter.java:69) at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:82) at java.lang.Thread.run(Thread.java:750)"
08/29/2024 10:32 AM
I am working on this POC will get back to you with working JAR
08/29/2024 10:44 AM - edited 08/29/2024 10:45 AM
08/29/2024 12:35 PM
Just an update simple code with logger is working for me. Now will test with Login
08/29/2024 01:59 PM
I am also getting same error for with parameter but without parameter how you have configured in workflow
08/30/2024 12:20 AM - edited 08/30/2024 12:55 AM
@rushikeshvartak can you show me how you have sent the simple parameter? which was the format?
sendEmail({'TEST'})??
They are upgrading me to 24.7 just now... maybe later all will work 😄
Kind regards,
Albert.
08/30/2024 08:14 AM
Parameters are not working for me also. Can you show how you made worked without parameter
08/30/2024 08:37 AM
Without using parameter just like this works fine for me:
In case that you want to use the same csv file that i use the contents must be (WorkflowAPIParameters.csv --> NO COLUMN NAMES):
USERNAME;;PASSWORD;;SAV_URL;;FROM_EMAIL;;TO_EMAIL;;INFORMATION E-MAIL SUBJECT;;MAIL_TEMPLATE_CSV_FILE_UPLOADED
08/30/2024 09:13 AM
2024-08-30T12:11:17-04:00-ecm----2024-08-30T16:11:16.774365717Z stdout F org.jbpm.pvm.internal.wire.WireException: method justCall(java.util.HashMap) is not available on object vartak.rushikesh.RushikeshVartakSaviyntAuthentication.SaviyntApp@11977869 (vartak.rushikesh.RushikeshVartakSaviyntAuthentication.SaviyntApp)
I tried same getting error
same works with jar connector
09/01/2024 10:56 AM
Hello @rushikeshvartak ,
You need to declare it with hasmap but empty also so it get's called as it's expecting it in the declaration even tough later is not used as you cannot send any parameter.
This is what I found after a lot of testing. For me sincerely is a problem to be addressed via new implementation idea or via bug as not being able to pass parameters to a function is really limiting a lot the capabilities of a workflow.
Also the documentation of what can be done and what cannot be done via workflow and other methods should be much more clear in the documentation as nothing is specified there of what are the capabilities ... it says you can call a function and that's all it says.
Please let me know if there's anything I can do to help on this matter. I've also opened a ticket so they can check with engineering team.
Kind regards,
Albert.
Kind regards,
Albert.
09/01/2024 11:26 AM - edited 09/01/2024 11:28 AM
Finally my code is working.
below are default parameters you get
public static void sendEmail(HashMap<String, String> wfInput)
you don’t need and can’t pass parameters from workflow
09/01/2024 11:29 AM
Hello @rushikeshvartak ,
Wonderful news, can you share the code or the changes you did in order to see them so I can apply the same?
Kind regards,
Albert.
09/01/2024 11:40 AM - edited 09/01/2024 04:52 PM
Your code has some loopholes so fixed those
Code Snippets
Code :
Property File:
Property Files Content :
Password is Base 64 : https://www.base64encode.org/
Workflow Block
Logs Validation
Output :
From Saviynt:
From Windows:
Code: High Level
This class is designed to execute a workflow action, fetch configurations from a CSV file, authenticate with an API, and send an email based on a template. The class is equipped to handle both Windows and Unix-based file paths and includes options for detailed logging.
listOfFiles(File dirPath):
getDefaultConfig():
executeWorkflowAction(Map<String, String> wfInputMap):
09/01/2024 11:29 AM
Hi @rushikeshvartak , we are only allowed to pass below 3 right?
and utilize the same in jar code
09/01/2024 11:45 PM
Hello @rushikeshvartak ,
Please upload the java class so everyone can benefit from the info. I'm missing the functions you are calling in that snippet so I'm not sure if they are custom or already existing in the prodduct.
Kind regards,
Albert.
09/02/2024 06:08 AM
I can’t upload java code unfortunately due to security reason . I have give logic all and your code had all things. If you still face issue happy to help
09/02/2024 07:32 AM - edited 09/02/2024 08:11 AM
You can rename it as .txt like I did before to send you the code. The idea is to have something that people can use when they see the post as this is a recurrent question in the forum.
Kind regards,
Albert.