Content Management and Capture

 View Only
  • 1.  Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Thu September 19, 2024 04:03 PM

    Hi,

    I am trying to retrieve the Page Field Value and set the Value on the same page after performing the regex on it using custom action. I validated that the dco is a Page Level, but not able to retrieve any field values for the variables on the page.

    I am attaching a class which is called from the custom action. can you please check and let me know why I am not able to retrieve the field values from the page?

    I am calling the 

    ExtractByRegexPageNewV3 as an action from one of the Task and it is being executed at the Page Level. 

    I verified that the current DCO is Page level, but can't get the value of a field from currentDCO. can some one let me know what I am doing Incorrectly?

    Thanks for the help.



    ------------------------------
    T K
    ------------------------------

    Attachment(s)

    rtf
    ImagineCommon CS.rtf   8 KB 1 version


  • 2.  RE: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Fri September 20, 2024 01:41 AM

    It would be helpful to see what values are actually being passed as parameters.  Also, there appear to be a number of changes/experiments in the code, which could be thinned out to make the example code clearer.

    But I suspect there may also be a misunderstanding in play.  You mention that can't "retrieve any field values for the variables on the page".  Fields and Variables are two different things in Datacap and they are referenced differently.  If you are passing in the name of a Field and are expecting to get the value of a Variable - or vice versa - you will not meet with much success.

    As a first step, ensure that the SmartParm values take a format like @P.VariableName or @P\FieldName.



    ------------------------------
    Robert Stegall
    ------------------------------



  • 3.  RE: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Fri September 20, 2024 12:40 PM

    First, it's always a good idea to make sure you're at the level you expect -- for example, something like this to find the batch:

                if (this.CurrentDCO.ObjectType() != Level.Batch)

                {

                  TDCOLib.IDCO parent = CurrentDCO.Parent();

                  while (parent.ObjectType() != Level.Batch)

                  {

                      parent = parent.Parent();

                  }

                  oBatch = parent;

              }

    Or this to make sure that you're really at the page level:

                if (this.CurrentDCO.ObjectType() != Level.Page)

                {

                  RRLog.WriteEx(5, "Error! Must be called at page level");

                  return false;

              }

    Now for the main question -- you say that you're "not able to retrieve any field values for the variables on the page." Can you be a bit more precise? I'm guessing that you're referring to fields like an end user would see -- for example, "Port of Loading" for a Bill of Lading document -- but you could also be referring to a variable on a field, like the position of the field on the page.

    KEY POINT: Fields like an end user would see are IDCO objects, just like a batch, document, or page. So you need to find the field as an IDCO, then get its value.

    Variables on a field (or on a batch, document, or page) are different -- they are properties whose value you can get or set.

    In any case, if you're looking for a field like an end user would see, you can do this (assuming you know the name of the field):

                oField = oPage.FindChild(labelName);

    For example,

                oField = oPage.FindChild("Port of Loading");

    Then to get the value of the field, you'd do something like:

              String fieldValue = oField.Text;

    If you want the value of a variable on the page (or similarly for the value of a variable on a batch, document or field), you can do something like

              String variableValue = oField.get_Variable("variableName");



    ------------------------------
    Scott Sumner-Moore
    ------------------------------



  • 4.  RE: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Fri September 20, 2024 05:13 PM

    Thank you for the reply.

    Below is the method I am calling from custom action class by passing the smartParameter and parameterName (not using them for now)
    In the log file, it says that it is a Page level object. I also add some comments in the code to show what was the output. 
    public string ParseSmartParameterPageV2(string smartParameter, string parameterName)
    {
    if (this.CurrentDCO.ObjectType() == Level.Batch)
                {
    this.RRLog.Write(string.Format("The DCO is Batch Level"));
    }
    if (this.CurrentDCO.ObjectType() == Level.Document)
    {
    this.RRLog.Write(string.Format("The DCO is Document Level"));
    }
    if (this.CurrentDCO.ObjectType() == Level.Page)
    {
    this.RRLog.Write(string.Format("The DCO is Page Level"));
    }
    if (this.CurrentDCO.ObjectType() == Level.Field)
    {
    this.RRLog.Write(string.Format("The DCO is Field Level"));
    }
    var oPage = this.CurrentDCO;
    //var oFeild1 = oPage.FindChild("LMLOTADD"); -- No Result
    //string feildValue2 = oFeild1.Text; -- No Result
    //Blank Values for Page Variable Names or batch dir-- 004 batch
    /*for (int i = 0; i< oPage.NumOfVars(); i++)
    {
    string feildValue3 = oPage.GetVariableName(i);
    string feildValue3 = oPage.BatchDir;
    this.RRLog.Write(string.Format("The Page Level Variable Name is", feildValue3));
    }*/
    for (int i = 0; i< oPage.NumOfVars(); i++)
    {
    string feildValue3 = oPage.BatchDir;
    this.RRLog.Write(string.Format("The Page Level Variable Name is", feildValue3));
    }
    Invoice Page 



    ------------------------------
    T K
    ------------------------------



  • 5.  RE: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Fri September 20, 2024 05:46 PM

    In the code above, if you take this code:

    for (int i = 0; i< oPage.NumOfVars(); i++)
    {
    string feildValue3 = oPage.BatchDir;
    this.RRLog.Write(string.Format("The Page Level Variable Name is", feildValue3));
    }
    And replace it with this code:
    for (int i = 0; i< oPage.NumOfVars(); i++)
    {
    string variableName = oPage.GetVariableName(i);
    string variableValue = oPage.GetVariableValue(i);
    this.RRLog.Write(string.Format($"Variable {variableName} is {variableValue}"));
    }
    what results do you get?
    Also, with regard to getting Field values...are you at a place in the workflow where Fields have been created?  The creation of Fields is performed by an action in the model (CreateFields), so if this hasn't occurred yet, there are no Fields to find.  This might explain why your commented-out sample code did not return anything for LMLOTADD (though you would have received a null pointer exception since FindChild() would not have returned anything.


    ------------------------------
    Robert Stegall
    ------------------------------



  • 6.  RE: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Fri September 20, 2024 06:37 PM

    Along with Robert's good points and suggestions, if the LMLOTADD field has been created but has no value, then this line wouldn't return a null value

    var oFeild1 = oPage.FindChild("LMLOTADD"); -- No Result
    so you wouldn't get a null pointer exception in this line, but it would return either a null or empty string:
    string feildValue2 = oFeild1.Text; -- No Result


    ------------------------------
    Scott Sumner-Moore
    ------------------------------



  • 7.  RE: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions

    Posted Fri September 20, 2024 07:36 PM

    Thank you, this got me the results. It gave me the variable names and variable values. I created a new field AddressTemp has value that I need to work with and update. can you also please let me know how do I update the variable value  once I make changes to it?

    Thanks



    ------------------------------
    T K
    ------------------------------