Before Context Send Hook
For more information about InContext messaging, see the Infor Enterprise Server InContext Modeling Development Guide.
We recommend that you use the After Mappings
hook of the individual context
message, but use the Before Context Send
hook in these cases:
- If you must make changes based on multiple context messages in the context.
- To add a complete new message for which standard Infor LN does not have a template.
The input argument of this hook is an XML node with the messages that are built by the standard session. Example XML:
<masterNode>
<message id="com.infor.ln.businesscontext" name="inforBusinessContext">
<entities>
<entityType>company</entityType>
<id1>1910</id1>
<visible>false</visible>
<readonly>true</readonly>
</entities>
<screenId>ln_tccom4500m000</screenId>
<logicalId>lid://infor.ln.701</logicalId>
<contextId>102320113837_33032_20</contextId>
<entities INFOR_CONTEXT_ARRAY="true">
<entityType>InforERPEnterpriseCommonInternalBusinessPartner</entityType>
<id1>TDCUS0016</id1>
<name>Acme Construction</name>
<readonly>false</readonly>
<accountingEntity>infor.ln.1910</accountingEntity>
<drillbackURL>?LogicalId=lid://infor.ln.701&ICMDrillback=true&Session=tccom4100s000&SessionIndex=1&Filter=VERDVVMwMDE2&Enc=1&Mode=64</drillbackURL>
<visible>true</visible>
<lnTable>tccom100</lnTable>
</entities>
</message>
</masterNode>
How to investigate this XML, see Steps to investigate XML.
The example earlier has this equivalent in JSON:
{
"type": "inforBusinessContext",
"data": {
"screenId": "ln_tccom4500m000",
"logicalId": "lid://infor.ln.701",
"entities": [
{
"visible": false,
"readonly": true,
"entityType": "company",
"id1": 1910
},
{
"accountingEntity": "infor.ln.1910",
"visible": true,
"readonly": false,
"entityType": "InforERPEnterpriseCommonInternalBusinessPartner",
"id1": "TDCUS0016",
"name": "Acme Construction",
"drillbackURL": "?LogicalId=lid://infor.ln.701&ICMDrillback=true&Session=tccom4100s000&SessionIndex=1&Filter=VERDVVMwMDE2&Enc=1&Mode=64",
"lnTable": "tccom100"
}
],
"contextId": "102320113837_33032_20"
}
}
An example to send an additional context message, in case you have a contextual application that listens to this message:
function extern void before.context.send(long i.msgs.node)
{
long new.message
new.message = xmlNewNode("message", XML_ELEMENT, i.msgs.node)
xmlSetAttribute(new.message, "id", "com.acme.my.message")
xmlSetAttribute(new.message, "name", "acmeMyMessage")
xmlNewDataElement("user", logname$, new.message)
xmlNewDataElement("businessPartner", tccom100.bpid, new.message)
}
When this hook is executed, the values of (key) fields that are used to build up the standard part of the context message, are available. You can explore those fields by selecting the Standard Context Message extension type in the Extension Modeler and viewing the mapping. Ensure to delete that extension type again if you do not extend that particular message. You can use the available (key) fields to read additional data from the database, if required.