Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Agent for Validate Form Content

Status
Not open for further replies.

cchoriego

Programmer
Jul 4, 2007
2
SV
I run an agent in order to validate the form’s data. I use a field called ValidationMessage to store the validation result, if the field is empty the validation is OK, and the document must be saved. But when the agent ends, the field is empty even if it was filled within the agent. I have been verified the agent execution with the agent’s log.

This is the code:

FORMULA LANGUAGE ACTION IN FORM

@Command([RunAgent]; "ProductGroupSaveChanges");

@UpdateFormulaContext;

@If(@GetField("ValidationMessage")="";
@Do(
@Command([FileSave]);
@Command([FileCloseWindow])
);
"")

JAVA AGENT

Session session = getSession();
AgentContext agentContext = session.getAgentContext();

Log log = session.createLog("Agent Log");
log.openAgentLog();

Document doc = agentContext.getDocumentContext();

if (doc.getItemValueString("ProductGroupID").length() == 0)
{
doc.replaceItemValue("ValidationMessage", "The Product Group ID is empty...");
} else if (doc.getItemValueString("ProductGroup").length() == 0)
{
doc.replaceItemValue("ValidationMessage", "The Product Group name is empty...");
}

log.logAction(doc.getItemValueString("ValidationMessage"));


 
Why not use a simple Validation Formula ?

Have a Computed for Display field check your field values and fill in the ValidationMessage field for you, like this :
Code:
@if(!@isdocbeingsaved;@return("");"");
WkValidation1 := @if(ProductGroupID="";"The Product Group ID is empty";"");
WkValidation2 := @if(ProductGroup="";"The Product Group name is empty";"");
FIELD ValidationMessage := @if(WkValidation1="";WkValidation2;WkValidation1);
""
I'm sure this will work.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
I must use a java angent because the agent will do more work ( connect to SQL database)

Thanks...
 
Does your SQL connection need to work if the doc is not validated ?

If not, you should still use the Validation Formula to ensure that the SQL part only executes when necessary.

Now that you mention it, is your agent signed by an authority that has Unrestricted execution access ? I suppose the SQL server is not on the Domino server ? If so, you are requesting an external access, and that operation is not approved for Basic Execution rights.

I suggest you consult your Admin and ensure that the signature you use has the proper scheduled access rights for that operation.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top