Leave feedback
  • Dynamic Sorting in Streamserve Story Teller

Write an Article
Monday 12 February, 2018
Mithu Ghosh Mithu Ghosh
1 likes 38 views

The scope of this document is to help us understand the steps that we should follow while implementing the Dynamic Sorting on a Table Data using Repeater. We can apply this Dynamic sorting on on multiple fields based on some conditions

1.      Storyteller – So we should apply this change inside Storyteller. To achieve the goal, We should have the complete details of the requirement like –

        a.     ConditionsOn which we have to apply the Sorting

        b.     FieldsDifferent fields which will sort the data.

Script on the Repeater - In our case, we have both the required things and we have applied the Dynamic sorting as follows –

Suppose if we have to apply the sorting based on 5 fields which are coming from xml, then we have to store those fields in to 4 different variables for every condition. Like in our case, we have 6 different conditions for six different sorting. So we have applied below script on the repeater, which will repeat the sorted data –

 //Purpose of this script is to add the sorting criteria for different types of merchandise invoice

//----------------------------------------------------------------------------------------------------

$message = "";

$idx = 0;

$InvoiceType = stEvalXPath("/data/message/InvoiceType");

//<xpath>*[name()=$sortKey1]</xpath>,0,0,;<xpath>*[name()=$sortKey2]</xpath>,0,0,;<xpath>*[name()=$sortKey3]</xpath>,0,0,;<xpath>*[name()=$sortKey4]< /xpath>,0,0,;<xpath>*[name()=$sortKey5]</xpath>,0,1,

if(num(&CustomerFormatCode)  = 1 or num(&CustomerFormatCode)  = 10) //MerchandiseInvoiceAlphaHU

{

                        $sortKey1 = "ServiceLevel";

                        $sortKey2 = "HUNumber";

                        $sortKey3 = "Description2";

                        $sortKey4 = "Description";     

                        $sortKey5 = "";           

}

else if(num(&CustomerFormatCode)  = 7)   //MerchandiseInvoiceAlpha

{

                        $sortKey1 = "Description2";

                        $sortKey2 = "Description";

                        $sortKey3 = "ServiceLevel";

                        $sortKey4 = "";

                        $sortKey5 = "";           

}

else if(num(&CustomerFormatCode) = 8)                  //MerchandiseInvoiceNoSort

{

                        $sortKey1 = "SamePOFlag";

                        $sortKey2 = "LineNumber";

                        $sortKey3 = "";

                        $sortKey4 = "";

                        $sortKey5 = "";           

}

else if(num(&CustomerFormatCode)  = 9)  //MerchandiseInvoiceAlphaSL

{

                        $sortKey1 = "ServiceLevel";

                        $sortKey2 = "Description2";

                        $sortKey3 = "Description";

                        $sortKey4 = "";

                        $sortKey5 = "";           

}

else if(num(&CustomerFormatCode)  = 15) //MerchandiseInvoiceAlphaDept

{

                        $sortKey1 = "CustomerDepartmentNumber";

                        $sortKey2 = "Description2";

                        $sortKey3 = "Description";

                        $sortKey4 = "ServiceLevel";

                        $sortKey5 = "";           

}

else if(num(&CustomerFormatCode) = 19)                //MerchandiseInvoiceAlphaIPC

{

                        $sortKey1 = "MaterialPriceGroup";

                        $sortKey2 = "Description2";

                        $sortKey3 = "Description";

                        $sortKey4 = "ServiceLevel";

                        $sortKey5 = "";           

}

 

else if($InvoiceType= "ZF2D")            //Dropship --"VendorName":"SA" "SuppInvoiceNumber":"SA" "BOMIndicator":"SD" "Description":"SA"

{

                        $sortKey1 = "VendorName";

                        $sortKey2 = "SuppInvoiceNumber";

                        $sortKey3 = "Description";

                        $sortKey4 = "";

                        $sortKey5 = "BOMIndicator";

}

else

{

                        $sortKey1 = "";

                        $sortKey2 = "";

                        $sortKey3 = "";

                        $sortKey4 = "";           

                        $sortKey5 = "";           

}

 

So, in the above Script field CustomerFormatCode contains the value on which we have to apply the different sorting. And we have stored those Sorting fields in to different variable for each of the condition. So lets take the first condition –

            if(num(&CustomerFormatCode)  = 1) //MerchandiseInvoiceAlphaHU

{

                        $sortKey1 = "ServiceLevel";

                        $sortKey2 = "HUNumber";

                        $sortKey3 = "Description2";

                        $sortKey4 = "Description";     

}

 

Comments (0)

   


Post comment