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 . For example, the script may have changed the value of a field, this change will be ignored, unless it calls "save" prior to exiting.

 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.

 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:

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.

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'.

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

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'.

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

It is useless to call setMessage() with setRedirect since there will be no 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 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.

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"

Related articles