# How do I convert this rule to action?

**URL:** <https://community.auth0.com/t/how-do-i-convert-this-rule-to-action/113786>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [August 16, 2023, 6:23pm UTC](https://community.auth0.com/t/how-do-i-convert-this-rule-to-action/113786 "2023-08-16T18:23:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnationalwala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dnationalwala/32/49974_2.png) [@dnationalwala](https://community.auth0.com/u/dnationalwala)\
**Post date:** [August 16, 2023, 6:23pm UTC](https://community.auth0.com/t/how-do-i-convert-this-rule-to-action/113786/1 "2023-08-16T18:23:47Z")

</div>

As rule is deprecating in near future, I want to convert this rule to action:

```auto
function (user, context, callback) {

  user.awsRole = 'arn:aws:iam::1234567890:role/Auth0v2,arn:aws:iam::1234567890:saml-provider/Auth0';
  user.awsRoleSession = user.name;

  context.samlConfiguration.mappings = {
    'https://aws.amazon.com/SAML/Attributes/Role': 'awsRole',
    'https://aws.amazon.com/SAML/Attributes/RoleSessionName': 'awsRoleSession'
  };

  callback(null, user, context);

}

```

I tried to convert it as following for action:

```auto
exports.onExecutePostLogin = async (event, api) => {
 const user = event.user;
  user.awsRole = 'arn:aws:iam::1234567890:role/Auth0v2,arn:aws:iam::1234567890:saml-provider/Auth0';
};

```

However it shows the warning:

```auto
Property 'awsRole' does not exist on type 'User & { multifactor?: string[] | undefined; } & { identities: UserIdentity[]; }'.(2339)

```

---

<div class="post-metadata">

**Author:** ![staff1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/staff1/32/12715_2.png) [@staff1](https://community.auth0.com/u/staff1)\
**Post date:** [September 10, 2023, 6:09am UTC](https://community.auth0.com/t/how-do-i-convert-this-rule-to-action/113786/2 "2023-09-10T06:09:18Z")

</div>

This worked for me:

```auto
exports.onExecutePostLogin = async (event, api) => {
  api.samlResponse.setAttribute("https://aws.amazon.com/SAML/Attributes/Role", "arn:aws:iam::1234567890:role/Auth0v2,arn:aws:iam::1234567890:saml-provider/Auth0");
  api.samlResponse.setAttribute("https://aws.amazon.com/SAML/Attributes/RoleSessionName", event.user.name);
};

```

Good general info [here](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions) on migrating from rules to actions, and check out these references on the [event](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object) and [api](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/api-object) objects

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 18, 2023, 3:06pm UTC](https://community.auth0.com/t/how-do-i-convert-this-rule-to-action/113786/3 "2023-10-18T15:06:40Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
