Question

Create case in tenant layer with Email listener from shared layer

HI,

We have multitenant environment with multiple tenants. We have email listener at shared layer. Out requirement is to create a case in tenant layer based on some condition like email ID. I am setting tenant name in email activity for Requestor page but still it is creating case in Shared layer. Can any one know how to create case in tenant layer from shared layer through email listener.

***Moderator Edit-Vidyaranjan: Updated Platform Capability***

Correct Answer
December 5, 2019 - 7:14am

Hi ,

You can use below code it will switch to the tenant context From shared layer

try{
com.pega.pegarules.priv.context.PegaRequestor p=((com.pega.pegarules.priv.context.PegaRequestor)tools.getRequestor());
p.setTenantName(tenantId);
LogContext.put("tenantid", tenantId);
}catch (Exception e)
{
  oLog.error("**** message:" +e.getMessage());
}

After switch to the tenant create a case in tenant layer once your case creation is done by using the below code you can switch back to shared layer

try{
com.pega.pegarules.priv.context.PegaRequestor p=((com.pega.pegarules.priv.context.PegaRequestor)tools.getRequestor());
p.setTenantName("shared");
LogContext.put("tenantid", "shared");
}catch (Exception e)
{
  oLog.error("**** message:" +e.getMessage());
}

Comments

Keep up to date on this post and subscribe to comments

December 5, 2019 - 7:14am

Hi ,

You can use below code it will switch to the tenant context From shared layer

try{
com.pega.pegarules.priv.context.PegaRequestor p=((com.pega.pegarules.priv.context.PegaRequestor)tools.getRequestor());
p.setTenantName(tenantId);
LogContext.put("tenantid", tenantId);
}catch (Exception e)
{
  oLog.error("**** message:" +e.getMessage());
}

After switch to the tenant create a case in tenant layer once your case creation is done by using the below code you can switch back to shared layer

try{
com.pega.pegarules.priv.context.PegaRequestor p=((com.pega.pegarules.priv.context.PegaRequestor)tools.getRequestor());
p.setTenantName("shared");
LogContext.put("tenantid", "shared");
}catch (Exception e)
{
  oLog.error("**** message:" +e.getMessage());
}

December 12, 2019 - 12:16pm

Thanks a lot Subramanyam for the help, it worked fine.