Wednesday 19 February 2014

Working with the alerts in AX 2012

Dynamics Ax2012 facilitates the Alerts mechanism out of the box which can be used commonly across the modules for new implementations. Especially to fulfill the users wish on getting alerts and helping them in their daily activities.

Let us take few business scenarios as example to know how it plays a big role in alerting the user.
Susan from procurement team handles the RFQ (Request for quotation) process in the organization. He processes 100 RFQs each day. To track the Expiry date of the RFQ and compare the quotations received from different suppliers on completion of “Expiry date” is a tedious work for him. He wants to be alerted a day before the expiry date of the RFQ. How can we help him?
Rajat is an accounting manager and who is not involved in PR approvals but still he wants to be alerted or notified whenever a purchase requisition is approved.
Sunny is inventory manager and wants to be alerted whenever Inventory clerk creates an item in the Item master.

Dynamics AX2012 alerting mechanism can be used to address all these scenarios. AX2012 has two kinds of alerts which can be be used accordingly to achieve the same.
  • Change based alerts
  • Due date alerts
Change based alerts: With respect to a particular field we can setup the alert rule to alert the specific user. As per our scenario,  I am going to create an alert rule to alert someone when the PR is approved.
Go to PR header>focus on the status field in the header> right click >Create alert rule, which opens the below form. It has below 4 alerting options



  • Has changed – Alerts whenever the value in this field has changed
  • Is set to – Alerts whenever the field is set to a particular value
  • Create and deleted: whenever a record has been created or alerted
We can use “Is set to” option here to alert whenever PR “status” is set to – Approved. In the “Alert who” node specify the user who should be alerted.

Due date alerts:
Similarly, for the due date alerts, select the date field you want to get the alerts for >Right click>Create alert rule



Choose the event “due in” and specify the days i.e., how many days before you want to alert the user. Jump on the other events that you are seeing to know how you can make the best use of it.
Similarly, using the event “Record has been created” will alert the user when a record is been created in that table.

Sticky notes: How can we alert multiple users for the event? Create another alert rule and specify the different user id .
What if a user wants to be alerted only when the POs from particular vendor are invoiced? Just use the select button to specify the condition to meet to get the alert. (Apply this querying based on the client requirements).

Considerations:
Just creating the alert rule is not enough to get the alert. You will also need to work on initiating the batch processing to get the alerts triggered.

Go to system administration>setup>Alerts> Change based alerts and Due date based alerts to route it through batch processing.


In the form, select the batch processing check box and click recurrence to define recurrence interval for the alerts triggering.

After doing this, go to system administration>inquiries> Batch jobs to ensure whether the batch job created. (You will get to see the alerts only if the job is added to this batch jobs form)


Last but not least, set up the user options for the users who want to be alerted.
Go to system administration>Users>Select each user>go to options and click the “notifications” tab.


Set the value in minute’s field to see the pop up for every x minutes. Now, everything is done and we should receive the alerts.



AX home and all the forms will have the alerts symbol, clicking on which will show you the notifications.
Setting “Send alert as e-mail message” option sends the notifications as e-mail.

Sunday 16 February 2014

Conformation Message Box in AX 2012

Dialogbutton    dialogBtn;
;
dialogBtn  =   Box::yesNo("Are you sure to continue ", dialogButton::Yes, 
                                         "Choose your option");
if (dialogBtn == dialogButton::Yes)
   {
        info( "Process will be continued ");
   }
else
     if (dialogBtn == dialogButton::No)
       {
          info( "Process stopped");
       }

Thursday 13 February 2014

an unbalanced x++ TTSBEGIN/TTSCOMMIT pair has been detected.causes of this include(a) too many

Hi ,

Sometimes we het the TTSBEGIN unbalancing error.

Error: 
clip_image001 

To resolve this error this TTS level should be ZERO, Run this job to get rid of that error, this job will find the tts level where its greater than zero and make it zero by calling TTSABORT. 

static void resetTTS(Args _args)
{
while (appl.ttsLevel() > 0)
ttsAbort;
}


ttsBegin: marks the beginning of a transaction. This ensures data integrity, and guarantees that all updates performed until the transaction ends (by ttsCommit or ttsAbort) are consistent (all or none). 
ttsCommit: marks the successful end of a transaction. This ends and commits a transaction. MorphX guarantees that a committed transaction will be performed according to intentions.

WINAPI claas in Axapta 2012 and Its Use

Like most AX developers I use the WINAPI class quite often. Its a very useful class when handling files that need to be accessed outside of the AX environment

  static void FO_WinApi(Args _args)
  {
      str     root        = "C:";
      str     path        = "C:\\dionne";
      str     fileName    = "SalesInvoice.pdf";
      str     fileName2   = "SalesInvoice1.pdf";
      str     file        = path + "\\" + fileName;
      str     file2       = path + "\\" + fileName2;
      int     x, y;
      ;

      // Does folder exist?
      print WinAPI::folderExists(path);

      // Does file exist?
      print WinAPI::fileExists(file);

      // Copy file.
      print WinAPI::copyFile(file,file2);

      // New file exists?
      print WinAPI::fileExists(file2);

      // Delete new file.
      print WinAPI::deleteFile(file2);

      // New file still there?
      print WinAPI::fileExists(file2);

      // Get current cursor position.
      [x, y] = WinAPI::getCursorPos();

      print x;
      print y;

      // Get time and date format.
      print WinAPI::getSystemLocaleDateStr();
      print WinAPI::getSystemLocaleTimeStr();

      // Gets current computer name.
      print WinAPI::getComputerName();

      // Gets total disk space.
      print int2str(WinAPI::getDiskTotalSpaceInKb(root)
             / 1000) + " MB";

      // Gets current free space on disk.
      print int2str(WinAPI::getDiskFreeSpaceInKb(root)
             / 1000) + " MB";

      // Date when file was last accessed.
      print WinAPI::getFileAccessedDate(file);

      // Time when file was last accessed(In seconds).
      print WinAPI::getFileAccessedTime(file);

      // Gets path to temp directory.
      print WinAPI::getTempPath();

      // Gets a generated temporary filename, prefix "FO_".
      print WinAPI::getTempFilename(path, "FO_");

      pause;

  }
In addition to file information the WINAPI class can execute different file types from within Dynamics AX by of course using the file name as a parameter.
For example lets say you want to launch a PDF file saved in table within AX. WinAPI::ShellExecute() will do this for you

Wednesday 5 February 2014

Saturday 1 February 2014

Disabling form elements based on another form elements

Hi,

Sometimes we want to disable form element, depend upon some value or on some event of the same form element. we can do that , please refer below mentioned way, please view carefully so that you can modified as per your requirement.

As example, the CustTable form will be used. The example will disable the One-time customer checkbox on the General tab if the Mandatory credit limitcheckbox is checked on the same General tab.
Change form properties
  1. Select the Administration Field Group on the TabGeneral TabPage and set the AutoDataGroup Property to No.
  2. Select the Administration_OneTimeCustomer CheckBox field in the Field Group Administration and set the AutoDeclaration property to Yes.



create from methods for enable/disable

Create a new form method setAccessOneTimeCustomer:
void setAccesssOneTimeCustomer()     
{ 
   if (CustTable.MandatoryCreditLimit)     
    { 
       Administration_OneTimeCustomer.enabled(false);    
    } 
    else     
    { 
        Administration_OneTimeCustomer.enabled(true);     
    } 
    custTable_DS.refresh();    
}

call the form methods in active and modified methods

Call the newly created form method in the active method on the Data Sourceof the Form. As such, the second field will be enabled or disabled appropriately upon scrolling through the form.
public int active() 

{   
    int ret; 
    element.setAccesssOneTimeCustomer(); 
    ret = super(); 
    return ret; 
}


Call the newly created form method in the modified method on the field which should trigger the enabling or disabling. In our example, it is the fieldMandatoryCreditLimit. As such the second field, in our case OneTimeCustomerwil be enabled or disabled each time the value of MandatoryCreditLimit is changed.

public void modified()   
{ 
    element.setAccesssOneTimeCustomer();     
    super(); 
}



checkout

Open the CustTable form: check the field Mandatory credit limit: the field One-time customer will be disabled immediately.