Customer Portal

Comments 3

  • Avatar
    jraszyk
    0
    Comment actions Permalink
    Perhaps this example will help you. It will produce one output record for every non-empty value in the field1-field3 fields. Use this code in your Normalizer component.


    //#CTL2
    // This transformation defines the way in which a single input record is normalized
    // into multiple output records.
    string[] values;

    // This function is called for all input records.
    // It parses each single input record and returns the number of records
    // that should be created from such input record.
    function integer count() {
    integer notNulls = 0;
    if ($0.field1 != null) {
    values[notNulls] = $0.field1;
    notNulls++;
    }
    if ($0.field2 != null) {
    values[notNulls] = $0.field2;
    notNulls++;
    }
    if ($0.field3 != null) {
    values[notNulls] = $0.field3;
    notNulls++;
    }

    return notNulls;
    }

    // This function creates new records for the output, based on single input record
    // that has been parsed by the count() function.
    // It is called count() times for each input record.
    // The idx argument specifies which output record is being created,
    // its values range is from 0 to count() - 1.
    function integer transform(integer idx) {
    $0.date = $0.date;
    $0.session = $0.session;
    $0.field1_type = "string";
    $0.field1_value = values[idx];

    return 0;
    }
  • Avatar
    jraszyk
    0
    Comment actions Permalink
    Or you can use the approach presented in this thread.
  • Avatar
    kasturi
    0
    Comment actions Permalink
    Hi Jan,
    Thank you so much for the help. I really appreciate it. It worked . I added the types also along with the values. It woks perfectly.
    Thanks again.
    Kasturi

Please sign in to leave a comment.