Forum Discussion

amit_saroha's avatar
amit_saroha
New Contributor III
4 years ago

How to read expression file and run pipeline

Hi All,

I have an expression file with the below details and I want to read these job names from the expression file and understand how I can trigger three different pipelines based on these three values?

{
Job_1: ‘EBS_JOB1’,
Job_2: ‘EBS_JOB2’,
Job_3: ‘EBS_JOB3’
}

5 Replies

  • viktor_n's avatar
    viktor_n
    Contributor II

    Hi @amit.saroha,

    First you need to setup that Expression File inside the pipeline.

    1. Open “Edit Pipeline”.
    2. Create new field for Expression File.
    3. Select/Upload Expression File.
    4. Specify a name for that file.

    After that anywhere in the pipeline where you can write expressions, you will have an access to that file.
    You can access that file by typing lib. followed by the name of the file what you will specify inside the Edit Pipeline.
    Ex: lib.configFile

    Regards,
    Viktor

  • amit_saroha's avatar
    amit_saroha
    New Contributor III

    @viktor_n Thanks for your response. I have created and uploaded file and used it as you have shown but I am unable to understand how in the expressions I can read those three values and trigger one pipeline for each value. Could you please give some inputs on this?

    • viktor_n's avatar
      viktor_n
      Contributor II

      To be able to write expressions, this box needs to be checked.

      This would return the data inside the file.

      When you come to this point you can use .values() function, that will return list of the values.

      With JSON Splitter snap you could split that list and set this values inside the Pipeline Execute.

  • amit_saroha's avatar
    amit_saroha
    New Contributor III

    Thanks, @viktor_n - Thanks,

    Below is coming out of the output, could please suggest how I can have only below three values in my output.

    “Person_Details_HCM_to_EBS_Interface”
    “Assignment_People_Group_Details_HCM_to_EBS_Interface”
    “Assignment_Details_HCM_to_EBS_Interface”

    The output of mapper - Need above three only in output or in JSON splitter

    [
    {
    "INT_Batch_ID":
    9121
    "INT_MASTER_Log_ID":
    33814
    "HCM_Job":[
    "Person_Details_HCM_to_EBS_Interface"
    "Assignment_People_Group_Details_HCM_to_EBS_Interface"
    "Assignment_Details_HCM_to_EBS_Interface"
    60
    60
    "EBS_JOB1"
    "EBS_JOB2"
    "EBS_JOB3"
    "EBS_JOB4"
    "EBS_JOB5"
    "EBS_JOB6"
    60
    60
    ]
    }
    ]
    

    Error while using $HCM_Job.startsWith(“HCM_”) in JSON splitter path expression

    “error”:
    “Unable to read data from path: $.HCM_Job.startsWith(“HCM_”)”
    “reason”:
    “Expecting object for JSON-Path field reference ‘startsWith(“HCM_”)’, found: List”

    • viktor_n's avatar
      viktor_n
      Contributor II

      As I see you are serching for elements in “HCM_Job” list that contains “HCM”.

      Inside Mapper before Splitter put this expression.

      lib.ExpressionFile[0].HCM_Job.filter(el => el.contains("HCM")
      

      This expression will get only those elements that contains “HCM” inside.

      After that inside Splitter you will map this filtered list.