PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02/13/2015 2:55 PM by  Peter O
Creating/Manipulating Javascript Arrays in IPA
 8 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Woozy
Private
Private
Veteran Member
(3469 points)
Veteran Member
Posts:701


Send Message:

--
01/30/2015 5:20 PM

    Hi All,

    I have a situation where I need to create some JavaScript arrays to use within an IPA flow so I can store and manipulate values outside of a query loop.  I've tried several things, and I can't get anything to work.  I may be making it more difficult than it needs to be. 

    Have any of you been successful in doing this?  Can you share a simple example of creating an array, adding elements to it (like within a query loop) and then navigating within the array (for-each)?

    Thanks!  Kelly

    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    Woozy
    Private
    Private
    Veteran Member
    (3469 points)
    Veteran Member
    Posts:701


    Send Message:

    --
    02/02/2015 9:45 AM
    It just occurred to me that I should be able to write the data to a messagebuilder and then pull it back out using the dataiterator and manipulate it within the di loop. It isn't exactly what I was thinking, but I think it will work OK.

    Kelly
    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    Tim Cochrane
    Private
    Private
    Veteran Member
    (450 points)
    Veteran Member
    Posts:154


    Send Message:

    --
    02/02/2015 12:15 PM
    Kelly,

    I'll PM you a Landmark Security flow i've been working on where i'm building arrays, then using the data later on, but here's overview of my scheme:
    1. query for data, in this instance the ltm>security>IdentityActor class, then within the query loop do 1a and 1b:
    1a. assign data to a var, ex: identityActorRecord = FindIdentity_Actor+"~"+FindIdentity_Identity+"~"+FindIdentity_Service+"~"+FindIdentity_ServiceType (builds the individual records as comma delimited)
    1b. increment record counter and assign data from 1a to another var, ex: identityActorArray = identityActorArray+identityActorRecord+"|" (adds records to the "array" pipe delimted)

    Later on in the flow i'm manipulating individual records and adding to new Actors. I don't have the flow working 100%, but not due to any of the above.

    Hopefully my flow will help, or at least give you some ideas.
    Tim Cochrane - Principal LM/IPA Consultant
    Woozy
    Private
    Private
    Veteran Member
    (3469 points)
    Veteran Member
    Posts:701


    Send Message:

    --
    02/02/2015 12:27 PM
    Thanks Tim - I'll take a look at your sample flow.

    I appreciate your willingness to share!

    Kelly
    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    John Henley
    Private
    Private
    Senior Member
    (9563 points)
    Senior Member
    Posts:3205


    Send Message:

    --
    02/03/2015 6:51 AM
    Kelly, can you describe your business case in a little more detail? Are you trying to populate the array from within a query loop, and then use the array itself later in the flow to drive a looping process?
    Thanks for using the LawsonGuru.com forums!
    John
    Woozy
    Private
    Private
    Veteran Member
    (3469 points)
    Veteran Member
    Posts:701


    Send Message:

    --
    02/03/2015 11:08 AM
    Hi John,

    You'll probably shake your head at this one.

    The flow is supposed to calculate wages by quarter for each employee, but only for the dates the employee was in a Step&Grade schedule. This would be simple if we could use TimeRecord date - but they don't want to use that because they want the numbers to match what the employee sees on their check. So, I need to include any check that has any S&G dates within it - which causes the potential for duplicate records (i.e. if an employee moves to a different Step&Grade in the middle of a pay period).

    My flow uses a SQL query to pull workassignment history from TM (select workassignment records by employee where Step&GradeSchedule is not blank), then for each returned record I perform a SQL query against S3 that provides wage totals by CheckDate, based on WA-begin, WA-end, CheckDate, and TimercordDate. I then need to sum the total wage amounts by employee for the S3 data - but I need to suppress multiple entries of the same check date. I'm hoping to store the checkdate & amount in an array so I can then skip entries that will cause duplicates when I sum them up.

    Basically, out Comp team is wanting to use a calculation that isn't accurate - but they are willing to accept that it isn't accurate because it is easier to explain. So I'm having to create something that is close to what they want but that will cause duplication if I don't force it to ignore the dups.

    Ugh.

    Kelly
    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    Peter O
    Systems Analyst
    Independent
    Veteran Member
    (205 points)
    Veteran Member
    Posts:69


    Send Message:

    --
    02/13/2015 8:36 AM
    This might be a silly question, but why not use your SQL query to pull a unique record? You could eliminate all the other array-filtering from what I understand of your issue...

    "SELECT DISTINCT column_name,column_name" select the distinct check based on date column.
    Woozy
    Private
    Private
    Veteran Member
    (3469 points)
    Veteran Member
    Posts:701


    Send Message:

    --
    02/13/2015 9:31 AM
    Hi Peter O - I ended up finding a solution that didn't require me to mess with arrays. However, to answer your question, I do use SQL extensively. In this case, the issue is that I had data sources on two separate and unrelated systems, and the inner query was based on the outer query results. Because of this, I often had duplicate records based on the outer query results, and I couldn't do a distinct to eliminate those duplicates. For example, my outer query might return 3-6 records for an employee, and the inner record might return 3 records for each of the 3 outer records - however, some of those 9-18 records would be duplicates (same check date returned from 2 or more outer queries). That's why I was looking for an array solution.

    I ended up using check PayPeriodEndDates instead, which greatly simplified the issue. I just had to convince the business that it would provide them what they needed.

    Kelly
    Kelly Meade
    J. R. Simplot Company
    Boise, ID
    Peter O
    Systems Analyst
    Independent
    Veteran Member
    (205 points)
    Veteran Member
    Posts:69


    Send Message:

    --
    02/13/2015 2:55 PM
    Thanks for that update! makes sense.
    You are not authorized to post a reply.