Skip to main content

Triggers: Script Tips

Triggers: Script Tips

Here we will show you some tips about how to use scripts.

For more information you can visit the official documentation of Soffid

Write into a sync-server log

System.out.println("what you want......");

Recover data from a Soffid object when synchronizing

Recover data from Soffid object to sinchronize

Recover user name

name = source{"userName"};
Recover a custom attribute

Recover company (company could be a user custom attribute defined on metadata page)

comp = source{"attributes"}{"company"};

 

Recover the attribute value that will be sent
no = newObject{"userName"};
gn = newObject{"givenName"};
....
Recover the attribute value from the select

That info comes from the target system. In a synchronization process, the first thing that Soffid does, is to query if the account exists on the target system.

no = oldObject{"userName"};
gn = oldObject{"givenName"};
....

Use  existing services

serviceLocator.getUserService().....
serviceLocator.getAccountService().....
serviceLocator.......

Create a new Soffid object

mailDomain = new com.soffid.iam.api.MailDomain();
newUser = new com.soffid.iam.api.User();
newRol = new com.soffid.iam.api.Role();
............

Loop an object list

for(role : roleList){
  //TO-DO
  out.print(" Role: " + role.roleName + "\n");
}

Recover response

if (response!=null) {
  for (o : response.getObjects()) {
    if (o!=null && o{"result"}!=null) {
      //TO-DO
    }
  }
}

Send a text email 

serviceLocator.getMailService().sendTextMail("mail@soffid.com", "Subject", "Mail message");

Send a HTML mail 

serviceLocator.getMailService().sendHtmlMailToActors(<to>, <subject>, <html-body>);