Policy Automation for B2C Service

Get Involved. Join the Conversation.

Topic

    Aparajit Malli
    Auto-create "Incident" entity without Interview...
    Topic posted March 29, 2019 by Aparajit MalliBronze Medal: 1,250+ Points 
    86 Views, 2 Comments
    Title:
    Auto-create "Incident" entity without Interview Entity Collection
    Summary:
    Auto-create "Incident" entity without Interview Entity Collection
    Content:

    Hi,

         We have built an OPA Interview and successfully integrated with Service Cloud. 

    We have already setup entities in OPA rulebase like this. 

    1. Global(Contact)
    2. Financial Application Custom Object (child of Global)
    3. Incident (child of Financial Application Custom Object)

    OPA Interview will collect information for Global(Contact) and Financial Application Custom Object. But, I need to create an "Incident" automatically and default/hard-code with following values, without showing it in the OPA Interview. 

    • Incident.Primary Contact = logged in contact
    • Incident.Category = Financial Application

    Also, there should be only one "Incident" instance..When OPA Interview resumes, it should not create another Incident.  

    Basically, I am trying to do is this.. 

    if InstanceCount(all instances of Incident) = 0, then create new Incident with Category = Financial Application and Primary Contact = logged in contact

    Can anyone help me with translating this to OPA Rules or configuration?

     

    Thansks,

    Aparajit

     

    Thanks,

    AP

     

     

    Version:
    18D

    Comment

     

    • Jasmine Lee

      Entity instances can be created automatically through rules. Take a look at this example in the documentation: Worked example 2: Infer existence of entities

      Cheers,
      Jasmine

    • Davin Fifield

      Hi Aparajit, 

      As Jasmine points out, you'll need to infer an entity instance. 

      If your relationship from Financial Application to Incident is called "the incidents", then the following one line rule in a Word document would do that for you:

      the incidents ("application incident") exists

      The name of the incident in quotes doesn't really matter. This entity instance will only be created once for the interview session - if you the interview is saved and later resumed from a checkpoint.

      Then you would have additional rules to set the values of that single incident. Since there is only one, you can just have simple rules to do it:

      1. Set the contact ID for the incident to the contact ID that you've mapped in to a global attribute 
      2. Set the incident category to "Financial Application"