Restrict some elements of an Enum in a form

March 24, 2012 Leave a comment

Here is the code to restrict the enum element in the form.

public void enter()

{

super();

this.delete(enum2str(AddressType::Invoice));

}

disable form controls depending on other form control value

March 24, 2012 Leave a comment

Most of the times, we get the requirement like, based on the value of one form control, the other form elements should be disable.

In order to achieve this task, following steps are taken.

1. Create a new method in the form level, where the logic for enable or disable shoul be writen.

2. Call this new method in the active() method of the form datasource and modified() method of the form datasource field level.

fill a dialog field depending on the input of other dialog value

March 24, 2012 Leave a comment

This post describes how to fill the dialog field automatically with the end date of the month depending on the entered value for the start date.

e:g; Human Resources > Reports > Status lists > Absence status.

Go to the class HRMAbsenceStatusListPrint, which is the class related to the Absence status report used in this example.

Add a new method called dialogSelectCtrl, which looks like this:

public void dialogSelectCtrl()
{
 ;
 super(); 
// get the value entered by the 
// end-user for the startDate 
startDate = dialogStartDate.value();
 // only set the a value if the endDate 
// doesn’t have a value yet
if(startDate && !dialogEndDate.value()) 
{
 // set automatically the endDate equal to the end
 // of the month of the entered value by the end-user 
dialogEndDate.value(EndMth(startDate));
 }
 }

Edit the existing dialog method and add following line just before the return dialog line to call the logic implemented in the dialogSelectCtrl method:

public Object dialog()
{
 // call the dialogSelectCtrl method when a control is selected
 dialog.allowUpdateOnSelectCtrl(true); 
 return dialog;
}

customize the infolog message

March 24, 2012 Leave a comment

The infolog message can be easily customized to display the desired actions. We can achieve this by using sysInfoAction_TableField class. Here I want to open the custTable form upon clicking the infolog message.

static void customizeInfolog(Args _args)

{

CustTable           custTable;

;

select firstOnly custTable

where custTable.AccountNum  == “1301”;

info(strFmt(“Normal info message about customer %1”

,custTable.Name));

info(strFmt(“Information message opening the CustTable ”

+ “Form on customer %1 upon double clicking ”

+ “the information message”

,custTable.Name)

,””

,SysInfoAction_TableField::newBuffer(custTable));

}

 

Extract date from a datetime field

March 24, 2012 Leave a comment

Here is the code to get the date  value from a datetime field.

myDate = DateTimeUtil::date(datetime field);

Automatic setting of mail recipient and subject during posting

March 24, 2012 Leave a comment

This post describes how to set mail recipient and mail subject dynamically upon posting of a purchase order packing slip.

1. create a method initprintjobsettings() in the class purchformletter

void initPrintJobSettings()

{

}

2. Again  create a method with same name in the class purchFormLetter_Packingslip

void initPrintJobSettings()

{

    PrintJobSettings printJobSettings;
    ;
    printJobSettings =
         new PrintJobSettings(printerSettingsFormletter);
    // set the output format of the packing slip to PDF
    printJobSettings.preferredMailFormat(PrintFormat::PDF);
    // set the mail recipient (this could be parameterised,
    // in the example it is hardcoded)
    if (purchTable)
        printJobSettings.mailTo(“foo@hotmail.com”)
    // set the mail subject    if (purchTable)
        printJobSettings.mailSubject(‘@SYS72882’
           + “ “ + purchTable.PurchId);
    this.updatePrinterSettingsFormLetter(
        printJobSettings.packPrintJobSettings());

}

3. Call the method in the  main method of purchFormLetter class.

{

purchFormLetter.initPrintJobSettings();

}