Custom Page Designer Script Examples

These examples show some custom pages that incorporate scripting for additional feature functionality.

Note: This example uses sea.js and is valid when SEA is installed with Lawson Portal.

Creating a custom page to approve invoices

function ap_invoice_approval_data0_OnClickButton(dmeId, row)
{
    // create variables for data mapped from page
    var vServer=window.location.host
    var vCompany = page.dataSource["COMPANY"];
    var vAuthCode = page.dataSource["AUTH-CODE"];
    var vVoucher = page.dataSource["VOUCHER-NBR"];
    var vVendor = page.dataSource["VENDOR"];
    var vInvoice = page.dataSource["INVOICE"];
    var vProd = portalWnd.oUserProfile.getAttribute("productline");

    // simple check to see if a row was clicked and data exists
    if (vCompany=="")
    {
        alert("Please select an Invoice");
        return;
    }

    // space fill vendor field
    var nLength = vVendor.length;
    if (nLength < 9)
    {
        for (n=1; n < (10 - nLength); n++)
            vVendor = "%20"+vVendor;
    }
    nLength = vVoucher.length;
    if (nLength < 10)
    {
        for (n=1; n < (11 - nLength); n++)
            Voucher = "%20"+vVoucher;
    }

    // example of the original ap26 api
    //http://localhost/servlet/ags?_PDL=LIVE&_TKN=AP26.1&_LFN=ALL
       &_EVT=CHG&_RTN=
    //DATA&_TDS=IGNORE&_OUT=XML&FC=C&_EOT=TRUE&API-COMPANY
       =1&PT-API-AUTH-CODE=
    //1&LINE-FCr1=R&API-AUTH-CODEr1=1&API-BOUCHER-NBRr1=
    //%20%20%20%20%20%20%20245&API-VENDORr1=
    //%20%20%20%20%20%20112&API-INVOICEr1=TEST04

    // build the api for ap26 ags
    var s = portalWnd.AGSPath
    	+ "?_PDL=" + vProd
        + "&_TKN=AP26.1&_LFN=ALL&_EVT=CHG&_RTN=DATA&_TDS=IGNORE
          &_OUT=XML&FC=C"
        + "&API-COMPANY=" + vCompany
        + "&PT-API-AUTH-CODE=" + vAuthCode
        + "&LINE-FCr1=R"
        + "&API-AUTH-CODEr1=" + vAuthCode
        + "&API-VOUCHER-NBRr1=" + vVoucher
        + "&API-VENDORr1=" + vVendor
        + "&API-INVOICEr1=" + vInvoice
        + "&_EOT=TRUE";

    // send the api to the server
    var	oResponse=portalWnd.httpRequest(s);
    if (!oResponse || oResponse.status)
        return;

    // extract out a specified node from the return object
	// (note: 'selectSingleNode' is IE-only method)
    try {
        var vMessage = oResponse.selectSingleNode("//Message").text;
    } catch (e){}
    alert(vMessage + " - Now Refreshing");

    // refresh the page
    document.location.reload();
}

Displaying text in a custom page text box

function text0_OnClick(id,row)
{
    // select mapped data and create variables
    var vH=page.dataSource["HIGHEST-BAL"];
    var vC=page.dataSource["CURRENT-BAL"];
    var vT=(vH-vC);

    // create a text object
    var txtCalc=page.objects["text1"];
    txtCalc.text=(vT);
    txtCalc.render();
}

Retrieving system date and applying it as a select

This example uses sea.js.

function hr_new_employee_listing_dme_OnInit()
{
    // variable that determines the system data and deducts 30 days
    var sysDate = getDateWithinDays(getSysDate(),-30);

    // create new object
    var dmeObj = page.objects["hr_new_employee_listing_dme"];

    // add criteria to the object
    dmeObj.criteria += "SELECT=BEG-DATE%3E" + sysDate;
}

Launching a web page with values passed from a DME object

function_cue_custcollab_stock_txt_OnClick(id)
{
    var symbol=page.dataSource["ARCUSTFLDS.CUST-USER1"];
    var stockURL="http://quicken.com/investments/quotes/?symbol="+symbol;
    window.open(stockURL);
}

In this example, the first character of the data value is also passed.

function _cue_custcollab_news_txt_OnClick(id)
{
    // collect data for the variable
    var x=page.dataSource["ARCUSTFLDS.CUST-USER1"];

    // select the first character only
    x=x.substr(0,1);
    var symbol=page.dataSource["ARCUSTFLDS.CUST-USER1"];
    var stockURL="http://biz.yahoo.com/n/"+x+"/"+symbol+".html";
    window.open(stockURL);
}

Launching a form from a text object

In this example the form is filled with key fields from a DME object.

function _cue_custcollab_aging_txt_OnClick(id)
{
    var sHK="";
    var sCompany=page.dataSource["COMPANY"];
    if(sCompany=="")
    {
        alert("Please select a customer");
        return;
    }

    var nLength = sCompany.length;
    if (4-nLength > 0)
    {
        for (var n=1; n < 5-nLength; n++)
            sHK="0"+sHK;
    }	

    sHK+=sCompany;

    var sCustomer=page.dataSource["CUSTOMER"];
    var nLength = sCustomer.length;
    if (9-nLength > 0)
    {
        for(var n=1; n < 10-nLength; n++)
            sHK+="%20";
    }
    sHK+=sCustomer;

    var sURL= portalObj.path+"?_TKN=AR50.1&_ACM-COMPANY="+
        sCompany+"&_ACM-CUSTOMER="+sCustomer+"&_HK="+sHK;

    window.open(sURL);
}

Lawson Portal page variable examples

// product line from user profile data
var vProd = portalWnd.oUserProfile.getAttribute("productline");

// data mapped from dme nugglet to the page
var vCompany = page.dataSource["COMPANY"];
var vRecLoc = page.dataSource["REQ-LOCATION"];
var vReqNum = page.dataSource["REQ-NUMBER"];