| # To create functions for LN homepages Introduction When you create a homepage, you must create functions on the LN server, which contain the logic to display the homepage's workload items, alerts, and so on. To create a homepage function, complete the following steps: Log on to the LN server. Start the Program Scripts / Libraries (ttadv2530m000) session. Either create a library and start the editor, or edit an existing library. Add the function syntax to the library. Save and compile the library. You can now link the function to a homepage. For details, refer to To create LN homepages. Homepage function types For descriptions and examples of the following homepage function types, see the following section: A function to display workload items. A function to display alerts. A count function. A function to start a session. A report item function. Workload items function Interface
    function extern long <workloadFunction>(long i.node)
i.node has the following content:
    <CompanyInfo>
    		<compnr> </compnr>
    		<logcompnr> </logcompnr>
    		<fincompnr> </fincompnr>
    	</CompanyInfo>
Always returns an XML node:
    <WorkloadItems>
    	<Item>
    		<id> </id>
    		<label> </label>	Label in personalize dialog
    		[<type> </type>]	Long (could be extended in the future when there are requirements for it). If not specified, not possible to filter
    		[<unit> </unit>]	Only used for filter
    		<countFunction> </countFunction>
    		<sessionStartFunction> </sessionStartFunction>
    		[<supportCount> </supportCount>]	default = false
    		[<supportAmount> </supportAmount>]	default = false
    		[<additionalInfo> </additionalInfo>]	xml node which is send back to the backend for the count and start function to prevent additional reads.
    	</Item>
    	. . .
    </WorkloadItems>
Example
    function extern long get.dashboard.workload.items(long i.node)
    {
    	long	items
    	items = xmlNewNode("WorkloadItems")

    	< Add the Items >

    	return(items)
    }
The items node could look like the following:
    <WorkloadItems>
    	<Item>
    		<id>wl_1</id>
    		<label>Open Orders</label>
    		<countFunction>get.open.orders.count</countFunction>
    		<sessionStartFunction>start.open.orders</sessionStartFunction>
    		<supportCount>true</supportCount>
    		<supportAmount>false</supportAmount>
    		<additionalInfo>
    			<buyer>76300</buyer>
    		</additionalInfo>
    	</Item>
    	<Item>
    		<id>wl_2</id>
    		<label>Created Orders greater than</label>
    		<type>long</type>
    		<unit>Eur</unit>
    		<countFunction>get.create.orders.count</countFunction>
    		<sessionStartFunction>start.create.orders</sessionStartFunction>
    		<supportCount>true</supportCount>
    		<additionalInfo>
    			<buyer>76300</buyer>
    		</additionalInfo>
    	</Item>
    </WorkloadItems>
Alerts function Interface
    function extern long <alertFunction>(long i.node)
i.node has the following content:
    <CompanyInfo>
    		<compnr> </compnr>
    		<logcompnr> </logcompnr>
    		<fincompnr> </fincompnr>
    	</CompanyInfo>
Always returns an XML node:
    <Alerts>
    	<Item>
    		<id> </id>
    		<label> </label>	Label in personalize dialog
    		[<type> </type>]	Long (could be extended in the future when there are requirements for it). If not specified, not possible to filter
    		[<unit> </unit>]	Only used for filter
    		<countFunction> </countFunction>
    		<sessionStartFunction> </sessionStartFunction>
    		[<supportCount> </supportCount>]	default = false
    		[<supportAmount> </supportAmount>]	default = false
    		[<additionalInfo> </additionalInfo>]	xml node which is send back to the backend for the count and start function to prevent additional reads.
    	</Item>
    	. . .
    </Alerts>
Example
    function extern long get.dashboard.alerts(long i.node)
    {
    	long	items
    	items = xmlNewNode("Alerts")

    	< Add the Items >

    	return(items)
    }
The items node could look like the following:
    <Alerts>
    	<Item>
    		<id>al_1</id>
    		<label>Open Orders</label>
    		<countFunction>get.open.orders.count</countFunction>
    		<sessionStartFunction>start.open.orders</sessionStartFunction>
    		<supportCount>true</supportCount>
    		<supportAmount>false</supportAmount>
    	</Item>
    	<Item>
    		<id>al_2</id>
    		<label>Late Orders</label>
    		<type>long</type>
    		<unit>days late</unit>
    		<countFunction>get.late.orders.count</countFunction>
    		<sessionStartFunction>start.late.orders</sessionStartFunction>
    		<supportCount>true</supportCount>
    		<imageLarge>td/ipu/bipuoutbox.gif</imageLarge>
    		<imageSmall>td/ipu/bipuoutbox_s.gif</imageSmall>
    	</Item>
    </Alerts>
Count function Interface
    function extern void <countFunction >(long i.node)
i.node has the following content:
    <Item>
    		<id> </id>
    		<compnr> </compnr>
    		<logcompnr> </logcompnr>
    		<fincompnr> </fincompnr>
    		[<amount> <amount>]			If a type is defined
    		[<additionalInfo> </additionalInfo>]
    	</Item>
Return always an XML node:
    <Item>
    	<id> </id>
    	<description> </description>
    	[<count><count>]
    	[<amount><amount>]
    	[<amountDescription><amountDescription>]
    </Item>
Example
    function extern long get.create.orders.count(long i.node)
    {
    	string	id(5)
    	long	amount
    	long	infoNode

    	id = xmlDataElement$(i.node, "id", 0)
    	amount = xmlDataElement$(i.node, "amount", 0)
    	infoNode = xmlFindFirst("additionalInfo", i.node)

    	select . . .
    	. . .
    	return(node)
    }
The node could look like the following:
    <Item>
    		<id>wl_2</id>
    		<description>Orders greater than 100.000 Eur</description>
    		<count>5<count>
    </Item>
Function to start a session Interface
    function extern void <sessionStartFunction>(long i.node)
i.node has the following content:
    	<Item>
    		<id> </id>
    		<compnr> </compnr>
    		<logcompnr> </logcompnr>
    		<fincompnr> </fincompnr>
    		[<amount> <amount>]			If a type is defined
    		[<additionalInfo> </additionalInfo>]
    	</Item>
The function does not return anything, but should start a session. Example
    function extern void start.create.orders(long i.node)
    {
    	string	id(5)
    	long amount
    	id = xmlDataElement$(i.node, "id", 0)
    	amount = xmlDataElement$(i.node, "amount", 0)

    	. . .
    	start.session(., .,  ., .)
    }
The node could look like the following:
    	<Item>
    		<id>wl_2</id>
    		<amount>100000</amount>
    	</Item>
Report item function Interface
    function extern long <reportFunction>(long i.node)
i.node has the following content:
    	<CompanyInfo>
    		<compnr> </compnr>
    		<logcompnr> </logcompnr>
    		<fincompnr> </fincompnr>
    	</CompanyInfo>
Always returns an XML node:
    <Report>
    	<design> </design>	Name of the report design
    	[<parameterSession> </parameterSession>]	Session to start to change the parameters by the end user
    	[<parameter
    		[name=’. . .’] 	Attribute ‘name’ specifies the name of the parameter.
    	 > </parameter>]*	The value of each parameter should be specified.
    </Report>
Example
    function extern long purchased.order.amount.report(long i.node)
    {
    	long node
    	. . .
    	return(node)
    }
The node could look like the following:
    <Report>
    		<design>Purchased Order Amount</design>
    		<parameterSession>gazzzreptest</parameterSession>
    		<parameter name=’Period Table’>MONTH</parameter>
    		<parameter name=’Start Date’>Jan 01, 2006</parameter>
    		<parameter name=’End Date’>Dec 31, 2006</parameter>
    		<parameter name=’Buyer’>jsmith</parameter>
    		<parameter name=’Default Currency’>EUR</parameter>
    	</Report>
At runtime this node creates the following link to the report:
    ... /run?__report=Report\Purchased Order Amount.rptdesign&Period Table=MONTH&Start Date=Jan 01, 2006&End Date=Dec 31, 2006&Buyer=jsmith&Default Currency=EUR
The user can click the link to display a graph. For an example, see the following figure: When you have defined a parameter session for the report, a Parameters button is displayed. When the user presses the button, the corresponding parameter session starts. With the session you created, the user can change the parameters. The parameter session is an LN session. Therefore, when developing this session, you have all LN programming possibilities such as browsing and so on. In the choice.end.program section you must call the send.parameters.to.report(…) function. This function requires the parameters specified as pairs, with the name of the parameter followed by the value. See the following example:
    choice.end.program:
    before.choice:
    	send.parameters.to.report("Start Date", start.date, "End Date", end.date)
At runtime, this code results in a call to the backend. For example:
    <RESPONSE>
       <ARG NAME="callResult">
           <callResult>
               <SESSION ID="6-2" STATE="CLOSED">
                   <REPORTPARAMETERS>
                       <parameter NAME="Start Date">Jan 01, 2007</parameter>
                       <parameter NAME="End Date">Jan 31, 2007</parameter>
                       <processinfo>report_0</processinfo>
                   </REPORTPARAMETERS>
               </SESSION>
           </callResult>
       </ARG>
    </RESPONSE>
As a result of this call, the homepage does the following: Searches for the correct report and replaces the parameters with the new values. The values are only replaced for the parameters sent to the report. For parameters not sent to the report, the values stay the same. Refreshes the pane where the graph is displayed. Related topics Homepages introduction Homepage structure Homepages delivery Predefined homepages delivered by Infor To install and configure Homepages To create LN homepages |