Happy Business Starts Here

Create subscription using REST API

Highlighted
Savvy Scholar

Create subscription using REST API

I need to create a subscription using Workflow REST API but the subscriptions created have to be for the 1st of next month when the workflow is run and not the day the workflow runs. (Say workflow runs on 18th August. Subbscirption should get created for 1st September)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Valued Scholar

Re: Create subscription using REST API

You can try the below liquid code in your callout and use "{{year}}-{{month}}-{{day}}" wherever you need to define date:

 

{% assign year = Data.Workflow.ExecutionDate | date: '%Y-%m-%d' | slice: 0,4 %}
{% assign year = year | plus: 0 %}
{% assign month = Data.Workflow.ExecutionDate | date: '%Y-%m-%d' | slice: 5,2 %}
{% assign month = month | plus: 0 %}
{% assign day = Data.Workflow.ExecutionDate | date: '%Y-%m-%d' | slice: 8,2 %}
{% assign day = day | plus: 0 %}
{% if month >= 1 and month <= 11 %}
   {% assign month = month | plus: 1 %}{% assign day = 1 %}
{% elsif month == 12 %}
   {% assign year = year | plus: 1 %}{% assign month = 1 %}{% assign day = 1 %}
{% endif %}

View solution in original post

2 REPLIES 2
Highlighted
Valued Scholar

Re: Create subscription using REST API

@sayam Could you please provide some more details on your requirement? Do you want your new subscription to be billed starting Sept-01?

Highlighted
Valued Scholar

Re: Create subscription using REST API

You can try the below liquid code in your callout and use "{{year}}-{{month}}-{{day}}" wherever you need to define date:

 

{% assign year = Data.Workflow.ExecutionDate | date: '%Y-%m-%d' | slice: 0,4 %}
{% assign year = year | plus: 0 %}
{% assign month = Data.Workflow.ExecutionDate | date: '%Y-%m-%d' | slice: 5,2 %}
{% assign month = month | plus: 0 %}
{% assign day = Data.Workflow.ExecutionDate | date: '%Y-%m-%d' | slice: 8,2 %}
{% assign day = day | plus: 0 %}
{% if month >= 1 and month <= 11 %}
   {% assign month = month | plus: 1 %}{% assign day = 1 %}
{% elsif month == 12 %}
   {% assign year = year | plus: 1 %}{% assign month = 1 %}{% assign day = 1 %}
{% endif %}

View solution in original post