All product information in wiki.bizagi.com is only valid for Bizagi BPM Suite 9.1.X.
For newer Bizagi BPM Suite versions (10.X and up) please visit the User Guide.
 

Converting to string (ToString)

From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS

Jump to: navigation, search

Converting to String (toString)

The toString function converts an object to its string representation so that it is suitable for display. Although .NET language uses the function ToString, you should type it as toString in order to ensure compatibility between the Bizagi .NET and JEE version. This should not be an issue.

The toString method has the following structure:

Attribute.toString();

Where Attribute is the name of the attribute you wish to convert to string.

Example

A Clothing Store manages discounts according to the season and has developed a process in Bizagi. The Sales manager has defined the following discounts table which is a parameter entity called DISCOUNTS:

 

Season

Start Date

Final Date

Discount

Winter

12/21/12

3/19/12

5%

Spring

3/20/12

6/19/12

10%

Summer

6/20/12

9/21/12

0%

Fall

9/22/12

12/20/12

5%


When a sales agent enters the products of a sale, the system evaluates the current date, establishes the current season and according to this, defines the discount to apply.

In order for the system to establish the current season, the current date must be formatted and converted to string type to be able to execute an SQL Query.

The required expression to establish the right discount to apply is as follow:


//Get the current Date
var TodayDate= DateTime.Today

//Format and Convert to string date
TodayAsString = TodayDate.toString("yyyy-MM-dd");

//Get current Season
var filter = "StartDate <=" +"'"+ TodayAsString +"'" + "and FinalDate >= " + "'"+ TodayAsString +"'";

var DiscountTable=CEntityManager.GetEntity("DISCOUNTS").GetEntityList("","",filter,"");

for(var i=0;i< DiscountTable .Length;i++)
{

//Get discounts related to the current season
                var Discount = DiscountTable [i].Attributes["Discount"].Value;
}

First the current date is obtanied in a variable, then this date is formatted and converted by using the toString function. A filter is applied in order to obtain the current season. Finally the related discount is obtained.

<comments />