Problem

It is needed to design application so that it supports upgrades/downgrades of some service (usually subscription type).

Resolution

The best way is to introduce application resource under top-service:

<setting default-value="1" id="subscription_type" type="enum" visibility="hidden">
    <name>License Type</name>
    <choice id="1"><name>Free</name></choice>
    <choice id="2"><name>Basic</name></choice>
    <choice id="3"><name>Pro</name></choice>
</setting>

<resource id="subscription" class="item" limiting-setting="subscription_type">
            <name>Subscription Type</name>
            <description>Subscription Type</description>
</resource>

and point it via limiting-setting to a setting with type string:

Such scenario will require specific environment configuration which should be described in deployment guide:

  1. [Operations Automation] Create Resource Types:

    • based on 'Application' Resource Class
    • based on 'Application Resource (KB)' Resource Class
    • if your application has any other resources create them as well
  2. [Operations Automation] Create Service Template with Resource Types created on previous step.

  3. [Business Automation] Create new Resource Category ( Product Director > Resource Manager > Resource Categories), 'Webshop Display Type' should be 'Radio Button'.

  4. [Business Automation] Create a Composite Resource (Product Director > Resource Manager > Resource) for each choice (Free/Basic/Pro):

    • Name will be displayed to user during switch, choose something like 'APPLICATION_NAME Free'
    • Resource category created on step 3
    • Unit of Measure - unit
    • Type - Composite Resource

    Then navigate to 'Included Resources' in created composite resource > 'Add New Included Resource', find the resource you created on step 1 (based on 'Application Resource (KB)' Resource Class), specify amount, 1 to create Resource for 'Free'

    Repeat the steps to create Composite Resources for Basic and Pro, the values should be: Basic: 2, Pro: 3

  5. Create Service Plan and add Resource Rates for composite resources created on step 4, check "Show in CP" and "Show in Store" for all resource rates.

  6. To test the setup create an order for a customer, install application, navigate to Account > Buy Additional Resources, you should see a list of choices.

NOTE:

  1. Redefining settings from resources in sub-services does not work, such resources need to be used in top-service only.

  2. If resource type based on class application is changed during plan change existing application will be unprovisionined (configure remove) and provisioned anew (configure install) if auto-provisioning is enabled.

It happens if plans are based on different service templates containing different resource types, even if their settings are identical. Operations Automation treats them different and will uninstall instance during such change

Internal content

Link on internal Article