Community

How to get the field value of a table in process skill?

I have a document skill with a table:

I want to check in the process skill, if the extract returns any value or not. So I put an IF activity to ask for manual review when the value of one of the row is empty. 

 

Unfortunately the code didn't work. Could you point out my mistake?:

for (var i = 0; i < Context.Transaction.Documents[0].Fields.length; i++) {
    var currentField = Context.Transaction.Documents[0].Fields[i];
 
 
    if (currentField.Name  ==  "New Table"){
        for (var j = 0; j < currentField.Children.length; j++){
            var currentChildField = currentField.Children[j];
            if (currentChildField.Name == "Batch Number" && (currentChildField.Value == null  || currentChildField.Value == ""))
                return true;
           
            if (currentChildField.Name == "Production Date" && (currentChildField.Value == null  || currentChildField.Value == ""))
                return true;
           
        }
        return false  
    }
       
}
return false

Was this article helpful?

0 out of 0 found this helpful

Comments

2 comments

  • Avatar
    Radityo Pratomo

    I also tried to call the column just like in the advanced scripting rule by using "New Table/Batch Number". It also didn't work

    for (var i = 0; i < Context.Transaction.Documents[0].Fields.length; i++) {
        var currentField = Context.Transaction.Documents[0].Fields[i];

        if (currentField.Name  ==  "New Table/Batch Number" && (currentField.Value == null  || currentField.Value == "")){
            return true;
        }
        if (currentField.Name  ==  "New Table/Production Date" && (currentField.Value == null  || currentField.Value == "")){
            return true;
        }
       
    }
    return false
    0
  • Avatar
    Tatiana Dyu

    Hi Radityo,

    You may need to add looping through instances as well, i.e.:

    for (var i = 0; i < Context.Transaction.Documents[0].Fields.length; i++)
    {
        var currentField = Context.Transaction.Documents[0].Fields[i];
        if (currentField.Name  ==  "Line Items")
        {
            for (var j = 0; j < currentField.Instances.length; j++)
            {
                 var tableColumns = currentField.Instances[j].Children;
                 for (var k = 0; k < tableColumns.length; k++)
                 {
                    var currentColumn = currentField.Instances[j].Children[k];
                    if (currentColumn.Name == "Description" && (currentColumn.Value == null || currentColumn.Text == ""))
                    {
                        return true;
                    }
                 }
               
            }
            return false;
        }
           
    }
    return false;

     
     
    0

Please sign in to leave a comment.