# Application scripts

* Most of Trustelem applications allow to set up a script in order to change the default behavior.

* With this script, it is possible to change the SAML or OpenID Connect attributes sent to an application.

* The language used is TypeScript.

#### Add a script

* Edit your app

* Click on **Custom claims** for OpenID Connect / **Custom scripting** for SAML

* Enter your script

[![script.png](https://trustelem-doc.wallix.com/uploads/images/gallery/2022-06/scaled-1680-/script.png)](https://trustelem-doc.wallix.com/uploads/images/gallery/2022-06/script.png)

#### Some examples for SAML applications

Add a constant attribute

```ts
msg.setAttr("attribute","value");   
```

Add an attribute containing Trustelem groups  

```ts
for(let g in groups){
    msg.addAttr("Groups",g);
}
```

Change the user email

```ts
if (user.email == 'john.doe@contoso.fr') {
    msg.setAttr("email","isabelle.doe@contoso.fr"); 
}
```

#### Some examples for OpenID Connect applications

Add a constant attribute

```ts
claims["attribute"] = "value"; 
```

Send a user attribute

```ts
claims["Profile"] = user.getAttr("profile");
```

Add an  attribute  containing  Trustelem  groups  

```ts
claims["Groups"] = JSON.stringify(groups);
```