Page tree
Skip to end of metadata
Go to start of metadata

EWset Module

EWset::save($outfileName)

Processes changes requested by the user and stores them in an xml file.

You should call this method at the end of your script to make your changes available to Agiloft. For example, the script may have changed the value of a field, this change will be ignored, unless it calls "save" prior to exiting.

Example

 If you used 

 my ($input_fname, $output_fname) =@ARGV;


at the start of your script to extract commandline params, then use 

 EWget::save($output_fname);


to save your changes.

 

EWset::setRecordField($fieldName, $fieldValue)

Assigns a value to the specified field in the record or sets the field to NULL if the value is undefined.

Example

 To set the value of the "email" field in the current record 

EWset::setRecordField("email",
"somemail@somesite.com"); 

Comment
This is the core function for change data in a your script.
This function manipulates both common fields and linked fields.

See Stringifiers Description for full description of acceptable formats for each type of data.

See also Linked Fields in Scripts chapter for more information.

EWSet::setExitAction($exitAction)

Determines what happens when the script exits. Option parameters are enclosed in double quotation marks.

Allowed options are:

  • "AcceptChanges" - the record is updated in the normal fashion. You can use setMessage to inform user about the details of update.
  • "RejectChanges" - the modification is rejected. User will be shown the record editing window, if the action was initiated via web interface.
  • "RejectChangesAndExit" - the modification is rejected and the user is automatically logged out. After logout, user will be redirected to URL specified by setRedirect function call.
  • "AcceptChangesAndExit" - the record is updated in the normal fashion and the user is automatically logged out. After logout, user will be redirected to URL specified by setRedirect function call.

Alternative to setExitAction

As an alternative to setExitAction, provided for compatibility with languages that do not allow strings to be returned, the script can provide an exit (return) code.

  • If the exit code is 0, the record is updated in the normal fashion. You can use setMessage to inform user about the details of update.
  • If the exit code is 1, the modification is rejected. User will be shown the record editing window, if the action was initiated via web interface.
  • If the exit code is 2, the modification is rejected and the user is automatically logged out. After logout, user will be redirected to URL specified by setRedirect function call.
  • If the exit code is 3, the record is updated in the normal fashion and the user is automatically logged out. After logout, user will be redirected to URL specified by setRedirect function call.

Formally speaking this function sets the value for the tag 'exitAction'.

EWset::setMessage($userMessage)

Send a message to the user.

This message will be shown to the user if the script is executed because the user has changed a record in GUI. Formally speaking, this method sets the value for the tag 'message'.

Example

EWset::setMessage("Please, select yes to accept
end-user agreement and create new account")

When a script blocks a record edit, it is a good practice to use setMessage to explain why the change was blocked and what the user should do. Of course, it can also be used to confirm success or provide some other message.

EWset::setRedirect($redirectUrl)

Sets the value of the URL that the user should be directed to if the script logs them out of Agiloft

The redirect URL should be absolute and include "http". It will be opened in the same browser window. Formally speaking, this method sets the value of the tag 'redirect'.

Example

EWset::setRedirect("http://www.enterprizewizard.com")

It is useless to call setMessage() with setRedirect since there will be no Agiloft page shown to display the message.

EWset Debug Functions

The following functions are mostly used for debugging scripts. 

EWset::setDebug($debugMessage)

Write to the log file (formally speaking, sets value for tag 'debug').

This message is saved to the Agiloft log. It can be useful for logging the result of a script or to debug the script.

EWset::setReport($reportMessage)

Sets a value in the record history

This message is stored in the record history. Formally speaking, this method sets the value for the tag 'report'.

Note: It is sometimes helpful to write a description of what the script did to the data and why.

EWSet::exit_ew ($exitAction, $outfileName)

Combination of functions EWSet::setExitAction($exitAction) and EWset::save($outfileName) with the same arguments and meanings.

Example

The function is able to get an exitCode directly, as $exitAction argument, thus the following pairs of values are equivalent: 
 

"AcceptChanges" or 0 or "0"
 

"RejectChanges" or 1 or "1"
 

"RejectChangesAndExit" or 2 or "2"
 

"AcceptChangesAndExit" or 3 or "3"