There are a variety of reasons to pass values between entities. It is PREFERABLE that you pass values using this method as opposed to entering global variables. Global variables should be avoided when possible.
Hyperlinks and Xephr functions should always use single quotes ( ' ) instead of double quotes ( " ).
Passing Values between Entities
Passing Values between Entities, opening in a new window
When creating this link, the Hyperlink To field will contain the function call, and the Hyperlink Scripted pop-list needs to be set to true.
Enter the Xephr function call for the entity that you are opening.
ShowEdit: Opens entity in Edit Mode.
ShowQbe: Opens entity in QBE Mode.
ShowList: Opens entity in List Mode.
ShowNew: Opens entity in New Mode
ShowReport: Opens report without running the parameter form.
ShowParameterForm: Opens report, running the parameter form first.
Show: Opens the entity in its default mode.
Add an open parenthesis (
Enter the entity that you are opening in quotes followed by a comma. 'entity',
The entity is optional. If moving within the same entity, you can omit the entity name.
If you are passing values, such as primary keys, enter the block and field, in the format block.field, to which the value will be passed on the new entity, in quotes followed by a comma 'BLOCK.FIELD',
If you are passing values, enter the code to obtain the field value that will be passed from the current entity, followed by a comma $$BLOCK.FIELD$$, or $$BLOCK.FIELD.first$$;
If you wish to set a temporary global on the entity that you are opening, enter the name of the global in quotes preceded by an asterisk, followed by a comma '*GLOBAL', If you wish to set a session global when the entity is opened, use 2 asterisks '**GLOBAL',
To define the value for the global, enter the code to obtain the field value that will be passed from the current entity, followed by a comma $$BLOCK.FIELD$$, or $$BLOCK.FIELD.first$$;
Repeat 5 thorough 8 for any additional values that you are passing. The final value will NOT be followed by a comma.
When all values have been entered, add a close parenthesis )
Always close with a semi-colon ;
As an example, imagine that you are viewing a list of sales orders on entity OQEM and you are going to add a link on the list block that will take you to the edit block to view a single sales order.
The primary keys are order_no and order_suffix. We will set the ORG_UNIT_ID global as a temporary global.
The entity will be opened in Edit mode, so start with ShowEdit.
ShowEdit
Add the open parenthesis.
ShowEdit(
Enter the entity that will be opened, in quotes followed by a comma. In this case, it's the same entity, OQEM. Since it's the same entity, the entity name is NOT required, but for this example, we will enter it.
ShowEdit('OQEM',
The primary keys will be passed to the new entity, order_no and order_suffix. The block on the entity being opened is OEHEAD. The field on the entity being opened is ORDER_NO for the order_no primary key. They are entered next in quotes followed by a comma.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO',
The value for the order_no primary key is in the order_no field on the oehead block of the oqem entity. It is entered next, followed by a comma.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$,
We now have to enter the order_suffix primary key information to pass it. The field on the entity being opened is ORDER_SUFFIX for the order_suffix primary key. It is entered next, in quotes, followed by a comma.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$, 'ORDER_SUFFIX',
The value for the order_suffix primary key is in the order_suffix field on the oehead block of the oqem entity. It is entered next, followed by a comma.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$, 'OEHEAD.ORDER_SUFFIX', $$OEHEAD.ORDER_SUFFIX$$,
Now enter the name of the global being created temporarily, preceded by an asterisk, in quotes, followed by a comma.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$, 'OEHEAD.ORDER_SUFFIX', $$OEHEAD.ORDER_SUFFIX$$, '*ORG_UNIT_ID',
Now enter the value to be assigned to the global, but NOT followed by a comma because it is the last value being passed.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$, 'OEHEAD.ORDER_SUFFIX', $$OEHEAD.ORDER_SUFFIX$$, '*ORG_UNIT_ID', ' $$OEHEAD.ORG_UNIT_ID$$
Add the close parenthesis.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$, 'OEHEAD.ORDER_SUFFIX',$$OEHEAD.ORDER_SUFFIX$$, '*ORG_UNIT_ID', ' $$OEHEAD.ORG_UNIT_ID$$)
End with a semi-colon.
ShowEdit('OQEM', 'OEHEAD.ORDER_NO', $$OEHEAD.ORDER_NO$$, 'OEHEAD.ORDER_SUFFIX', $$OEHEAD.ORDER_SUFFIX$$, '*ORG_UNIT_ID', ' $$OEHEAD.ORG_UNIT_ID$$);
Xephr function |
Entity you are going to (optional) |
Block and field to which a value is being passed |
Value on from block being passed in $$BLOCK.FIELD$$ format or hard coded in quotes |
Block and field to which a value is being passed |
Value on from block being passed in $$BLOCK.FIELD$$ format or hard coded in quotes |
Global being created temporarily, in quotes, preceded by an asterisk |
Value on from block being set as the value of the new global in $$BLOCK.FIELD$$ format or hard coded in quotes |
ShowEdit |
('OQEM', |
'OEHEAD.ORDER_NO', |
$$OEHEAD.ORDER_NO$$, |
'OEHEAD.ORDER_SUFFIX', |
$$OEHEAD.ORDER_SUFFIX$$ |
'*ORG_UNIT_ID', |
$$OEHEAD.ORG_UNIT_ID$$); |
There will be times when a Xephr function will be set up to perform some action before opening a new entity, such as when you are inserting a new record. When this occurs, certain checks are done against the entity, such as checking to make sure that required fields are entered. For this reason, you should enter the javascript to be performed first. Then, you will put the code that is dependent upon the javascript executing successfully within a wrapper that checks to make sure that the javascript was successful before moving on.
Inserts, saves, and deletes set a property called lastResult. If this value is "true", the insert was successful. If the values is "false". it was unsuccessful.
The code looks like this
if ( lastResult)
{
//protected actions go here
}
For example:
Insert();
if ( lastResult)
{
ShowEdit('CONTACT_MASTER.CONTACT_ID','$$CONTACT_MASTER.CONTACT_ID$$');
}
Xephr is a registered trademark of NDS Systems, LC.
Copyright