Dittofi
Search…
Assign Event
The assign event allows you to change the value of a variable from within an event chain. In traditional programming this would be the equivalent of writing:
x = "some new value"
NOTE
The assign event does not update values in a database. It is only used to change the value of variable.
The assign event can be set up in 5 quick and easy steps.
  • Step 1. create an assign endpoint
  • Step 2. create an assign action
  • Step 3. create a variable in the action
  • Step 4. add the assign event
  • Step 5. build and test

Step 1. create an assign endpoint

Go to the endpoints tab in the Dittofi Design Studio and click on the "+ New Endpoint" button. Next give your endpoint the name "Assign", the path "/v1/assign/", description "Assign a variable to a new value" and the request method to "Get". The configuration for this is shown below.
Next, set a query variable that will be passed into the assign endpoint. Give this variable the type "text" and the name "SomeStartingValue".
Save and close the assign endpoint.

Step 2. create an assign action

Next, go to the actions tab and create a new action by clicking the "+ New Actions" button. Rename the action to "Assign" and link the trigger component of the action to the "Assign endpoint" that was configured in Step 1.

Step 3. create a variable in the action

The assign event requires that we switch the name of the variable passed in from our trigger endpoint to another value. This can be done in many ways however, the simplest way is to create a new global variable within the action. Let's do this now.
Create a new variable called "SomeNewValue" of type "text"
Note, the variable type must be equal to "text", since the value in our query variable is of type text.

Step 4. add the assign event

Next add the assign event by (A) pressing "+ Add Event" and (B) selecting the assign event from the event drop down menu.
Next, map the variable "SomeStartingValue" (created in step 1) to the variable "SomeNewValue" (created in step 3).
This means that the contents of SomeStartingValue is now equal to the contents of SomeNewValue. In programming this would be:
// The value here is passed in from the query variable
SomeStartingValue = "Some starting value"
​
SomeStartingValue = SomeNewValue
​
// Print the output "Some new value"
print SomeStartingValue
Next, add a description for your event and press "Save".
Finally, set the response variable in your trigger component to your starting value. This will be used to check that the assign event has worked correctly in step 4.

Step 5. build and test

To test the configuration, we first need to build the code. To do this, press "Build code". Once the code has been built, head back to the endpoints tab and open the "Assign endpoint" that was made in Step 1.
Click the "Run" button in the top left hand corner to test the endpoint and enter "some starting value" for the query variable that will be passed into the endpoint, as below.
If run successfully, you will see the Response code 200 and, in the body of the response, you will see the assign event returns the text "Some new value" which is the fixed text that you typed in Step 3.