Results 1 to 3 of 3

Thread: One-to-many records

  1. #1

    Default One-to-many records

    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
    Attached Files Attached Files

  2. #2
    Lavastorm Employee gmullin's Avatar
    Join Date
    May 2014
    Location
    Chicago
    Posts
    185

    Default

    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.

    Code:
    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. #3

    Default

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

    All the best this 2018 Yuletide Season!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •