> ### 6.11 Script Commands

> In addition to the standard ECMA JavaScript commands (see the PDF file ecma-262.pdf included with the software), Interstage BPM supports the following commands for exchanging information with the Server:

> void sec.addAttachment(String attachmentName, String attachmentPath)
> Adds the attachment stored at the specified path in the DMS to the process and gives it the specified name.
> sec.addAttachment("FSC News","C:\\Test\\FSC_news.doc");
> // Native DMS Adapter and NT LDAP DMS Adapter.
> sec.addAttachment("FSC News"," \\opt2\\netscape\\suitesopt\\iflow\\docs\\FSC_news.doc");
> // Solaris LDAP
> Date CurrentDate()
> Returns a JavaScript Date object (of type Date) containing the current date and time.
> uda.Date = CurrentDate();
> // equivalent to: var now = new Date(); NOTE: Will work correctly only if UDA Date is of type Date.
> Date DateAdd(String Date, Int Offset, String field)
> Returns a JavaScript Date object (of type STRING) containing the date and time that is the result of adding the Offset to the Date. The unit of time measure for the Offset is determined by the field. Valid field values are:
> "ss" - seconds
> "mi" - minutes
> "hh" - hours
> "dd" - days
> Example:
> var now = CurrentDate();
> uda.Date = DateAdd( now, 1, "dd");
> // NOTE: Will work correctly only if UDA Date is of type Date.
> If now (CurrentDate) has the following value:
> Tue Dec 02 2003 14:02:59 GMT-0800 (PST)
> tomorrow (DateAdd( now, 1, "dd")) has the following value:
> Tue Dec 03 2003 14:02:59 GMT-0800 (PST)
> boolean DateCompare(String Date1, String Operator, String Date2)
> Compares two date values. Returns true or false as the result of the comparison. Valid operators are:
> ">" - greater than
> "<" - less than
> ">=" - greater than or equal to
> "<=" - less than or equal to
> "==" - equal to
> "!=" - not equal to
> Example:
> var now = CurrentDate();
> var tomorrow = DateAdd( now, 1, "dd");
> if (DateCompare(now, "<", tomorrow))
> ...; //... will execute because DateCompare evaluates to true.
> Integer DateDiff(String Date1, String Date2, String field )
> Subtracts Date2 from Date1. Returns the difference between these date/times in days, hours, minutes or seconds depending on the field value. Valid field values are:
> "ss" - seconds
> "mi" - minutes
> "hh" - hours
> "dd" - days
> Example:
> var now = CurrentDate();
> var tomorrow = DateAdd( now, 1, "dd");
> var diff = DateDiff(tomorrow, now, "dd"))
> //diff will have a value of 1.
> decimal DecimalAdd(Decimal Value1, Decimal Value2)
> Returns a JavaScript Decimal object that is the sum of the supplied parameters. Each of the Decimal functions such as DecimalMultiply, DecimalDivide, etc. are made only for use with BigDecimal type UDAs. Other regular functions will not work correctly with Big Decimals. However, the converse is not true. If any other data type is used as the parameters of one of these functions, the function first converts the parameter to Big Decimal data type.
> Example:
> int x = 39;
> var z = DecimalAdd("3.1416",x);
> If z is of Big Decimal data type, z = 42.1416. The result inherits the precision from the parameter with the most significant figures.
> boolean DecimalCompare(Decimal Value1, String Operator, Decimal Value2)
> Compares two Big Decimal values. Returns true or false as the result of the comparison. Each of the Decimal functions such as DecimalMultiply, DecimalDivide, etc. are made only for use with BigDecimal type UDAs. Other regular functions will not work correctly with Big Decimals. However, the converse is not true. If any other data type is used as the parameters of one of these functions, the function first converts the parameter to Big Decimal data type. Valid operators are:
> ">" - greater than
> "<" - less than
> ">=" - greater than or equal to
> "<=" - less than or equal to
> "==" - equal to
> "!=" - not equal to
> Example:
> var smallDecimal = "1.11";
> var largeDecimal = "22.22";
> if (DecimalCompare(smallDecimal, "<", largeDecimal))
> ...; //... will execute because DecimalCompare evaluates to true.
> Decimal DecimalDivide(Decimal Value1, Decimal Value2, Integer scale )
> Divides Value1 by Value2. Returns the result of this division. It uses the scale parameter to determine the number of significant digits for rounding. The rounding mode is always to round half up. The round-half-up rounding mode rounds towards the "nearest neighbor" unless both neighbors are equidistant. In that case, it rounds up. Behaves as for ROUND_UP if the discarded fraction is >= .5; otherwise, behaves as for ROUND_DOWN. Note that this is the rounding mode that most of us were taught in grade school.
> Each of the Decimal functions such as DecimalMultiply, DecimalDivide, etc. are made only for use with BigDecimal type UDAs. Other regular functions will not work correctly with Big Decimals. However, the converse is not true. If any other data type is used as the parameters of one of these functions, the function first converts the parameter to Big Decimal data type.
> Any integer can be used as a scale value. The scale defaults to 2.
> Decimal DecimalMultiply(Decimal Value1, Decimal Value2, Integer scale )
> Multiplies Value1 by Value2. Returns the result of this multiplication. It uses the scale parameter to determine the number of significant digits for rounding. The rounding mode is always to round half up. The round-half-up rounding mode rounds towards the "nearest neighbor" unless both neighbors are equidistant. In that case, it rounds up. Behaves as for ROUND_UP if the discarded fraction is >= .5; otherwise, behaves as for ROUND_DOWN. Note that this is the rounding mode that most of us were taught in grade school.
> Each of the Decimal functions such as DecimalMultiply, DecimalDivide, etc. are made only for use with BigDecimal type UDAs. Other regular functions will not work correctly with Big Decimals. However, the converse is not true. If any other data type is used as the parameters of one of these functions, the function first converts the parameter to Big Decimal data type.
> Any integer can be used as a scale value. The scale defaults to 2.
> Decimal DecimalSubtract(Decimal Value1, Decimal Value2 )
> Subtracts Decimal Value2 from Decimal Value1. Returns the difference between these values as a Big Decimal.

> void sec.deleteAttachment(String attachmentName)

> Deletes the attached file named as the argument.

> Array sec.getActivityAssignees()

> Returns an array of names of those users assigned to the current active Activity. This command is only useful in scripts that belong to an activity-such as a Role Script or an Epilogue Script.
> In the following example, the joinString function is used with getActivityAssignees to yield a comma-separated list of assignee names and assigns it to the user-defined attribute (UDA) Names:
> uda.Names=sec.joinString(sec.getActivityAssignees());

> String sec.getActor()

> Returns the name of the person who committed the work item that belonged to the current activity. This command should only be used in an Epilog Script.
> name= sec.getActor();

> Array sec.getAllAttachmentNames()

> Returns an array of names corresponding to all of the attachments on the current process. If there are no attachments on the process, this function returns an exception.
> In the following example, the joinString function is used with getAllAttachmentNames to yield a comma-separated list of attachment names and assign it to the user-defined attribute (UDA) AttNames:
> uda.AttNames = sec.joinString(sec.getAllAttachmentNames());

> Array sec.getAllAttributeNames()

> Returns an array of names corresponding to all of the attachments on the current process. If there are no attachments on the process, this function returns an exception.
> In the following example, the joinString function is used with getAllAttributeNames to yield a comma-separated list of attribute names and assign it to the user-defined attribute (UDA) AttrNames:
> uda.AttrNames = sec.joinString(sec.getAllAttributeNames());

> String sec.getAttachment(String AttachmentName)

> Returns the file location and file name of the attachment whose name is specified.
> uda.PathName=sec.getAttachment("MyAttachment");

> String sec.getActivityName()

> Returns the name of the current activity.
> uda.name=sec.getActivityName();

> long sec.getCurrentProcessId()

> Returns the ID of the current process.
> ID = sec.getCurrentProcessId();

> Array sec.getGroupMembers(String groupName)

> Returns an array of the members of the specified groupName from the directory service.
> In the following example, the joinString function is used with getGroupMembers to yield a comma-separated list of group members for the QA group and assign it to the user-defined attribute (UDA) Members:
> uda.Members = sec.joinString(sec.getGroupMembers("QA"));

> String sec.getProcessAttribute(String name)

> Returns the value of the process attribute that is specified.
> Example:
> var name = sec.getProcessAttribute("Name");

> int sec.getProcessAttributeType(String name)

> Returns the type of the specified process attribute as an integer. The integer return value corresponds to the data type of the specified process attribute. Use the following table to determine the data type:

> ###### Return Value | ###### Data Type
> 0 | Boolean
> 1 | String
> 2 | Integer
> 3 | Float
> 4 | Long Integer
> 5 | Double
> 6 | Short
> 7 | Byte
> 8 | Big Decimal
> 9 | Date

> The following is an example of how this function can be used:
> Value=sec.getProcessAttributeType("Name");

> String sec.getProcessDefinitionId()

> Returns the unique identifier of process definition that the current process instance belongs to. The following example sets this return value to the UDA ID.
> uda.ID = sec.getProcessDefinitionId();

> String sec.getProcessDefinitionName()

> Returns the name of process definition of the current process instance. The following example sets this return value to the UDA Name.
> uda.Name = sec.getProcessDefinitionName();

> String sec.getProcessDescription()

> Returns the description of the current process. The following example sets this return value to the UDA Description.
> uda.Description = sec.getProcessDescription();

> String sec.getProcessInitiator()

> Returns the user ID of the user who started the current process.
> uda.Initiator = sec.getProcessInitiator();

> String sec.getProcessName()

> Returns the name of the current process.
> uda.ProcessName = sec.getProcessName();

> Array sec.getProcessOwners()

> Returns an array of the owners of the specified process.
> In the following example, the joinString function is used with getProcessOwners to yield a comma-separated list of process owners and assign it to the user-defined attribute (UDA) Owners:
> uda.Owners = sec.joinString(sec.getProcessOwners());

> int sec.getProcessPriority()

> Returns the priority of the process.
> priority1= sec.getProcessPriority();

> String sec.getProcessTitle()

> Returns the title of the current process.
> title1= sec.getProcessTitle();

> String sec.joinString(Array)

> Returns a comma-delimited string generated from a string array of identifiers.
> In the following example, the joinString function is used with getProcessOwners to yield a comma-separated list of process owners and assigns it to the user-defined attribute (UDA) Owners:
> uda.Owners = sec.joinString(sec.getProcessOwners());

> void sec.setActivityAssignees(Array assignees)

> Takes the specified array of names and uses them to assign the work items for the current activity. This method should be used only in a Role Script (or JavaAction).
> In the following example, the splitString function generates an array of assignees from the specified comma-separated list of assignees. Then, setActivityAssignees assigns john, mary, and chris to the activity:
> sec.setActivityAssignees(sec.splitString("john,mary,chris"));

> void sec.setOwners(Array users)

> Sets the specified array of users as owners of the process instance.
> In the following example, the splitString function generates an array of owners from the specified comma-separated list of users. Then, setOwners assigns chris and david as owners of the process:
> sec.setOwners(sec.splitString("chris,david"));

> void sec.setProcessAttribute(String name, String value)

> Sets the value of the given process attributes.
> sec.setProcessAttribute("Name","FSC");
> The following statement performs the same action using "uda." notation:
> uda.Name = "FSC";

> void sec.setProcessDescription(String description)

> Sets the given string as the description of the process.
> sec.setProcessDescription("My Process description.");

> void sec.setProcessName(String name)

> Sets the specified string as the name of current process instance.
> sec.setProcessName("MyProcessName");

> void sec.setProcessOwners(Array users)

> Sets the specified array of users as owners of the process instance.
> In the following example, the splitString function generates an array of owners from the specified comma-separated list of users. Then, setProcessOwners assigns chris and david as owners of the process:
> sec.setProcessOwners(sec.splitString("chris,david"));

> void sec.setProcessPriority(int priority)

> Sets the process priority.
> sec.setProcessPriority(11);

> void sec.setProcessTitle(String title)

> Sets the specified string as the process title.
> sec.setProcessTitle("MyProcessTitle");

> Array sec.splitString(String commaSeparatedList)

> Returns an array generated from a comma-delimited list of identifiers. Note: the identifier values must not have any commas in them, and there is no escaping mechanism to allow commas to be included in the values.
> In the following example, the splitString function generates an array of owners from the specified comma-separated list of users. Then, setProcessOwners assigns chris and david as owners of the process:
> sec.setProcessOwners(sec.splitString("chris,david"));

> boolean toBoolean(String or Integer value)

> Convert the String or Integer value to a JavaScript boolean. The value can be either a String containing "true" or "false", or a number containing zero or non-zero. Returns true or false depending on the value. If the value parameter cannot be converted into a Boolean, then false is returned.

> string toDate(String or Integer value)

> Convert the String or Integer value to a JavaScript Date object. The value can be a String, a number, or a Date object. Returns a Date object that corresponds to the value. If the value parameter cannot be converted into a date, then the STRING Invalid Date is returned.
> Decimal toDecimal(Decimal Value, Integer scale )
> Converts the parameter specified as Value to a Big Decimal object. Returns the result of this conversion to the number of significant figures specified in the scale parameter. It uses the scale parameter to determine the number of significant digits to display.
> Each of the Decimal functions such as DecimalMultiply, DecimalDivide, etc. are made only for use with BigDecimal type UDAs. Other regular functions will not work correctly with Big Decimals. However, the converse is not true. If any other data type is used as the parameters of one of these functions, the function first converts the parameter to Big Decimal data type.
> Any integer can be used as a scale value. The scale defaults to 2.
> Float toFloat(String Value)
> Converts the parameter specified as Value to a Float object. Returns the result of this conversion as a Float data type.
> integer toInteger(String Value)
> Converts the parameter specified as Value to an Integer object. Returns the result of this conversion as an Integer data type.
> long toLong(String Value)
> Converts the parameter specified as Value to a Long Integer object. Returns the result of this conversion as a Long Integer data type.
> string toString(Value)
> Converts the parameter specified as Value to a String object. Returns the result of this conversion as a String data type.
> Appendix B
> Examples
> Examples: Some Typical Business Processes

> Interstage BPM can automate the following sample list of typical business processes:

> Create a Performance Review Process Definition
> Defect Tracking
> Disbursements
> Expense Reports
> Petty Cash
> Product Enhancement Request
> Product Problem Report
> Purchase Requisition
> Report or Document Review
> Status Reports
> Timesheets
> Travel Requests
> Create a Performance Review Process Definition

> A periodic performance review process to measure and improve staff effectiveness will be used as an example. Here are the steps you might take to create a new performance review process definition:

> 1. Use the current method you use for performance reviews as the model for the process definition or design a new review process.

> Determine the following information:
> · The activities which take place in the process
> · The different decisions which an individual can make in response to each activity
> · The sequence of the activities
> · The data required to perform an activity
> · By whom the activities must be performed

> To illustrate, assume that you have designed the simple review process which is shown in the following workflow:

> · To start the process, the Manager fills out the manager's section of the review form and sends the form to the employee.
> · The employee does a self-appraisal and returns the form to the Manager who completes the form and then passes it on to her or his manager.
> · The Senior Manager approves or rejects the review. If he or she approves it, the employee and human resources are both notified.
> · If he or she does not accept it, the form goes back to the Manager who revises it and returns it to the Senior Manager.
> · This loop is repeated until the Senior Manager approves the review.
> · Once the employee and HR have acknowledged receipt of the approved review form, the process is complete.

> 2. Click Create New in the Process Designer.

> 3. Using the Node Toolbar, create the workflow so the sequence of activities appears as shown above.

> Click the icon, which is shaped like the node you want.
> Then click the process definition workspace to create that node.
> Move nodes by clicking the Select Tool at the right of the Node Toolbar. Then drag the node to its new location.
> Set properties or create forms by clicking the appropriate button.
> For more information, see "Creating and Modifying Process Definitions".

> 4. Use the Directory Service to define the members of the Manager, Sr. Manager, and Employee Roles.

> 5. From the first activity in the process, create a performance review form with the appropriate fields. Make one of the fields the Senior Manager approval field.

> Alternatively, you could use an existing performance review document as an attachment. In this case, you could not use a Conditional Node in the workflow. Instead, you would have to provide the Senior Manager an Approve and Reject option for the review activity.

> 6. For the Start Node and the remaining activities in the process, associate the form created in the previous step.

> 7. Select the Process Definition menu Save command and save the process definition under the name Performance Review

> The Performance Review Process

> The following process was created from the process definition that was created in the preceding section.

> Here are the events that would take place in the performance review process:

> 1. The Manager selects the Performance Review process definition from the Process Definitions List.

> 2. The Manager clicks New from the Process menu.

> 3. The review form opens and the Manager fills out his or her section of the review and saves the form.

> 4. The Self Appraisal activity shows up in the Employee's to-do list.

> 5. The Employee clicks the Activity tab in the Organizer and selects the Self Appraisal activity.

> 6. The Employee clicks Select Form () and opens the review form.

> 7. The Employee fills out his or her section of the review and saves the form.

> 8. The Employee clicks Submit in the Target Area.

> 9. The Manager Appraisal activity shows up in the Manager's to-do list.

> 10. The Manager clicks the Activity tab in the Organizer and selects the Manager Appraisal activity.

> 11. The Manager clicks Select Form () and opens the Review form.

> 12. The Manager completes the review and saves the form.

> 13. The Review Appraisal activity shows up in the Senior Manager's to-do list.

> 14. The Senior Manager clicks the Activity tab in the Organizer and selects the Review Appraisal activity.

> 15. The Senior Manager clicks the Select Form button (), opens the Review form, and reviews it.

> 16. If the Senior Manager approves the review, she or he clicks Approve in the Target Area, the Employee and HR are notified, and the process is complete. If the Senior Manager does not approve, she or he clicks Reject, and steps 9 through 16 are repeated until the review is acceptable.

> Appendix C
> Internationalization

Business Process Manager Help-Fujitsu Computer Systems Corporation Interstage Website Voice: (888) 248-9273 Interstage BPM Information