Skip to Content

C4C Form Ticket Summary logic using FormCalc in Adobe Lifecycle Designer (ALD)

Hi experts,

I am creating a form in Adobe Lifecycle Designer for a Ticket Summary. I want to print the item postions in the ticket in two tables dependent on the Product's InternalID. So one table for the time product and another for the kilometer product.

See Screenshot below for an example of the script in Row 1 of the table for time (here was the plan to hide all items with the product ID of kilometers; and for the other table the the other way round):

I created two dynamic tabels depended on the data and for the logic in the Script Editor I took the SAP Standard survey summary as example. Here is a logic in the section description field (certain Survey Type Code).

But it doesn't work...In the table for time all items appear and in the second one everything is empty except of 2 columns. What is wrong within this script?

If the data binding for the product's internal ID is:

ServiceRequest - Item - Product - InternalID - #data

Do I need to use in the script $data.ServiceRequest.Item.Product.InternalID or $data.ServiceRequest.Item.Product.InternalID.#data?

Thanks for help!

Best regards,

Deborah

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Mar 07 at 11:26 AM

    Hello Deborah,

    Sorry for being late in reply! I hope you have achieved what you wanted.

    First of all, I wanted a breif understaing when you say its not working. i.e No data is coming or something is coming in correct?

    For basic binding you don't require formcalc/js. ( TBH I have no experience in FormCalc , I use JS only for ALC)

    Suppose if u want to bind a simple field with a TextField , you can go to your DataConnection and select the field and #data.

    For Item ,

    1. create a bodypage with Flowed

    2. create a subform (optional ) with flowed content

    3. add table

    in DataRow , bind it with $.<<Bo>>.item[*]

    4. in column specify the field from item and bind it ( bind it with #data )

    $.<<Bo>>.item[*].<<anyfield>>

    Above will generate a very basic table , now in order to playaround with it i did below code for JS in ALC.

    	if (ltype.value == "101"){ //Work
    		wRow = this.frmTableItems.tblItems.rowItemContent.instanceManager.addInstance(1);
    		wlength = wlength + 1;
    		wRow.colItemDate.rawValue = ItemList.item(i).ActualDatePeriod.StartDateTime.value;	
    		wRow.colItemStartTime.rawValue = ItemList.item(i).ActualDatePeriod.StartDateTime.value;
    		wRow.colItemEndTime.rawValue = ItemList.item(i).ActualDatePeriod.EndDateTime.value;
    		wRow.colItemLineQty.rawValue = ItemList.item(i).ActualQuantity.value;
    		wRow.colItemLineDesc.rawValue = ItemList.item(i).Description.value;
    		this.frmTableItems.frmTableItemTotal.WorkTravelTotal.rawValue = this.frmTableItems.frmTableItemTotal.WorkTravelTotal.rawValue + wRow.colItemLineQty.rawValue;
    	}
    

    So basically based on itemType i am doing some manupulation. I hope it clarifies ur doubts.

    cheers.

    Dhruvin

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Dhruvin Mehta,

      the first 2 statements (1+2) are right. I just started to use js for binding because of your first answer. Now all data binding is again defined in the "Binding" tab of the object. I tried a second approach and comment the code. See screenshot below:

       FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow::initialize - (JavaScript, client)
      
      //Number of repeated DataRows (-1 because count from zero)
      var vRows = TableTime.DataRow.instanceManager.count-1;
      
      //Count Down-Loop deleting every Row that is not a Time Item (product unequal "Montage")
      for(var i=vRows;i>=0;i--){
      if(FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow[i].txtProduct != "Montage"){
      TableTime.DataRow.instanceManager.removeInstance(i);
      }
      }

      But it's still not working. As result I still get a complete table with all time and kiometer items. See screenshot below:

      Do you have an idea what's wrong?

      Best regards,

      Deborah

  • Mar 13 at 08:14 PM

    Hi i am not on my sysyem but a silly suggestion may be FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow[i].txtProduct here add ".rawValue" and check if it works

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Dhruvin Mehta,

      I decided not to use the copy function, because I think this is more complicated than to define the data binding in the script and just read out that data in the table that is relevant. So my plan is to insert an if-test before the data is read out in the time table and also an if-test for the kilometer table. Here is my code for the time table:

      FormServiceRequestConfirmation.Page2.frmZeiten.TableTime::initialize - (JavaScript, client)
      var ItemList = xfa.record.ServiceRequest.resolveNodes("Item[*]");
      var ilength = ItemList.length;
      
      for(var i = 0; i < ilength; i++){
      var vProduct = xfa.record.ServiceRequest.Item(i).Description.value;
             if (vProduct = "Montage"){
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.instanceManager.addInstance(1);
             var ItemID = xfa.record.ServiceRequest.Item(i).ID.value;
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtID.rawValue = ItemID;
             var ItemDescription = xfa.record.ServiceRequest.Item(i).Description.value;
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtProduct.rawValue = ItemDescription;
             var ItemActivity = xfa.record.ServiceRequest.Item(i).activity_D69RE3TX8TIX738N4U9BIZ85RDescription.value;   
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtProduct.rawValue = ItemActivity;
             var ItemServicetechnician = xfa.record.ServiceRequest.Item(i).ServicePerformerParty.FormattedName.value;   
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtProduct.rawValue = ItemServicetechnician;
             var ItemStart = xfa.record.ServiceRequest.Item(i).ActualDatePeriod.StartDateTime.value;
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtStart.rawValue = ItemStart;
             var ItemEnd = xfa.record.ServiceRequest.Item(i).ActualDatePeriod.EndDateTime.value;
             FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtEnd.rawValue = ItemEnd;
             }
      }

      However, I still have a problem with the definition of data out of XML in the script (especially with muplitle items -> item(i) is not working). That’s the result of my debugging...

      If I use the following code (based on your code/your way to define the data out of the XML), I just get an object reference displayed („Object-293420228“).

      var ItemList = xfa.record.ServiceRequest.resolveNodes("Item[*]");
      var ilength = ItemList.length;
      
      for(var i = 0; i < ilength; i++){
      var ItemTest = ItemList.item(i).resolveNode("Description");
      this.rawValue = ItemTest;
      FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.instanceManager.addInstance(1);
      }

      And if I try the following code I get the „real“ data of the first item displayed, but I cannot control which one of the multiple item description I’m getting displayed.

      var ItemTest = xfa.record.ServiceRequest.Item.Description.value;
      this.rawValue = ItemTest;

      And if I’m testing it to let a specific description get displayed with the following code, nothing happens at all - the text field stays empty. (tested with round and square clamps after item)

      var ItemTest = xfa.record.ServiceRequest.Item(2).Description.value;
      this.rawValue = ItemTest;

      Any idea on this?

      Thanks so much for your help…

      Deborah

  • Apr 09 at 09:25 AM

    Hi,

    First of all, How are u able to debug it :P ?

    Secondly, I am trying to understand your issue. You are adding item description on initialize event of the cell? Why do u need to resolve the node?

    var ItemTest = ItemList.item(i).resolveNode("Description");
    Can you please try below?
    
    ItemList.item(I).Description.value; don t resolve the node.
    

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Dhruvin Mehta,

      firstly: my debugging just is really complicated (every time to upload in C4C and test) and consits of creating a test text field where to test parts of the script...

      secondly: you're right! If I leave out the resolve Node it works and I see the data. But my next issue is with the addition of the row (instanceManager.addInstance).

      I tested the following script: (put the instanceManager.addInstance Row below the variables...)

      var ItemList = xfa.record.ServiceRequest.resolveNodes("Item[*]");
      var ilength = ItemList.length;
      
      for(var i = 0; i < ilength; i++){
      var vProduct = ItemList.item(i).Description.value;
          if (vProduct = "Montage"){
              
          var ItemID = ItemList.item(i).ID.value;
          FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtID.rawValue = ItemID;
          FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtProduct.rawValue = vProduct;
          var ItemActivity= ItemList.item(i).activity_D69RE3TX8TIX738N4U9BIZ85RDescription.value;       FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtActivity.rawValue = ItemActivity;
          var ItemServicetechnician= ItemList.item(i).ServicePerformerParty.FormattedName.value;    
          FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtServicetechnician.rawValue = ItemServicetechnician;
          var ItemStart= ItemList.item(i).ActualDatePeriod.StartDateTime.value;
          FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtStart.rawValue = ItemStart;
          var ItemEnd= ItemList.item(i).ActualDatePeriod.EndDateTime.value;
          FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.txtEnd.rawValue = ItemEnd;
          
          FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.instanceManager.addInstance(1);
          }
      }
      But the result is 2 table with just 1 row (see screenshot), and the data is also not "right" / not relative to the item product. So e.g. the Row in the Kilometer table displays also ID 10 (don't know why, the ticket just have once a ticket item with the ID 10) and the kilometer amount says 0.0. But in the ticket the first kilometer item is maintained with 200 km ...

      In the form I nevertheless put a relative data binding in the DataRow "$.ServiceRequest.Item[*]" (object hierarchy).

      
      
      //If I try it with the following code(set true), it also wrong... When 
      //compiling the form in the C4C ticket it's running very long and just an 
      //empty page is displayed.
      
      FormServiceRequestConfirmation.Page2.frmZeiten.TableTime.DataRow.instanceManager.addInstance(true);