LAE

 View Only
  • 1.  One-to-many records

    Employee
    Posted 12-18-2018 15:46

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tris_717684

    Hello LAE Users,

    I am need some help on writing a script to create one-to-many records. The attachment illustrates what I'm intending to perform.

    Hope somebody can help me. Many thanks in advance!

    Regards,

    tris
    Attachments:
    Sample.pdf


  • 2.  RE: One-to-many records

    Employee
    Posted 12-18-2018 17:08

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: gmullin

    Have a look at this. Not sure if you want to use the 'Days of Leave' column in the while loop or change it to not go past the 'End Date' value.

    node:Static_Data
    bretype:core::Static Data
    editor:sortkey=5c19895267015d92
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    ID Number:int,Staff Name,Leave Type,Start Date,End Date,Days of Leave:int
    12345678,Arnold Stallone,Annual Leave,17-Dec-18,21-Dec-18,5
    EOX
    editor:XY=160,150
    end:Static_Data
    
    node:Filter
    bretype:core::Filter
    editor:sortkey=5c19896b777472da
    input:@40fd2c74167f1ca2/=Static_Data.40fe6c55598828e5
    output:@40fd2c7420761db6/=
    prop:Script=<<EOX
    _startDate = 'Start Date'.date("DD-m-YY")
    _endDate = 'End Date'.date("DD-m-YY")
    
    # configure metadata for output pin
    output 1 {
    	emit int(null) as "ID Number", str(null) as "Staff Name", str(null) as "Leave Type",
    	date(null) as "Start Date", date(null) as "End Date", int(null) as "Days of Leave"
    	where false
    }
    
    i = 0  # set a counter for while loop
    while i < 'Days of Leave' { 
    	_newDate = _startDate.dateAdjust(i,"days")  # increament days
    	
    	# output pin
    	do output 1 {
    		emit 'ID Number', 'Staff Name', 'Leave Type', 
    		_newDate as "Start Date", _newDate as "End Date",
    		1 as "Days of Leave"
    	}
    	i = i + 1
    }
    EOX
    editor:XY=270,150
    end:Filter


  • 3.  RE: One-to-many records

    Employee
    Posted 12-20-2018 13:27

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tris_717684

    Thanks heaps @gmullin!!! it worked like magic!

    All the best this 2018 Yuletide Season!