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
Original Message:
Sent: Fri September 20, 2024 05:46 PM
From: Robert Stegall
Subject: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions
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
Original Message:
Sent: Fri September 20, 2024 05:13 PM
From: T K
Subject: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions
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
Original Message:
Sent: Fri September 20, 2024 12:39 PM
From: Scott Sumner-Moore
Subject: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions
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
Original Message:
Sent: Wed September 18, 2024 04:44 PM
From: T K
Subject: Issue with retrieving the Field Value of a Parameter from Page in Datacap Custom Actions
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
------------------------------