Saturday, December 29, 2018

Post handler for overriding table methods

Validate Write

[PostHandlerFor(tableStr(InventTable), tableMethodStr(InventTable, validateWrite))]
public static void InventTable_Post_validateWrite(XppPrePostArgs args)
{
      InventTable inventTable = args.getThis() as InventTable
      boolean ret = true;
      // Override the validations here and set the return value accordingly.
       Args.setReturnValue(ret);
}

modifiedField:-

[PostHandlerFor(tableStr(InventTable), tableMethodStr(InventTable, modifiedField))]
public static void InventTable_Post_modifiedField(XppPrePostArgs args)
{
        //Getting the table buffer
        InventTable inventTable = args.getThis() as InventTable
       //Getting the field id method argument.
        FieldId fieldModified = args.getArg("_fieldId");
        switch (fieldModified)
        {
            //Here you can write your logic on modified field method
                break;
        }

}

Post handler for class method

[PostHandlerFor(classStr(EcoResProductReleaseManager), methodStr(EcoResProductReleaseManager, release))]
public static void EcoResProductReleaseManager_Post_release(XppPrePostArgs args){
     EcoResProductReleaseManager releaseMgr;
    //Getting the class object
    releaseMgr     = args.getThis();
   //Getting the class parameter
   ItemId itemId  = releaseMgr.parmItemId();
   //Getting the method argument
    boolean itemCreation = args.getArg("_isCreation");
}

Control value and form event level for which auto declaration must be set true


[FormControlEventHandler(formControlStr(EcoResProductCreate, OKButton), FormControlEventType::Clicked)]
public static void OKButton_OnClicked(FormControl sender, FormControlEventArgs e)
{
       FormRun             element       = sender.formRun();
       //form control
       FormControl         modelGroupRef = element.design(0).controlName("ModelGroupId");
        Info(strfmt(“Model Group %1”, modelGroupRef.valueStr()));
       //form parameter
       ItemId              itemId        = element.parmItemId();
}

Form event handler Table Buffer on form closing event

[FormEventHandler(formStr(EcoResAttributeValue), FormEventType::Closing)]
public static void EcoResAttributeValue_OnClosing(xFormRun sender, FormEventArgs e)
{
     FormDataSource ecoResProduct_ds   =          sender.dataSource(formDataSourceStr(EcoResAttributeValue, EcoResProductAttributeValue));
      EcoResProductAttributeValue      ecoResAttributeValue = ecoResProduct_ds.cursor();

//Write your Code Here
} 

Form data source event handler

[FormDataSourceEventHandler(formDataSourceStr(EcoResProductDetailsExtended, InventTable), FormDataSourceEventType::Written)]
public static void InventTable_OnWritten(FormDataSource sender, FormDataSourceEventArgs e){
    FormRun                 form           = sender.formRun();
    FormDataSource          InventTable_ds =       form.dataSource(formDataSourceStr(EcoResProductDetailsExtended,InventTable)) as FormDataSource;
   InventTable             inventTable    = InventTable_ds.cursor();

// Write  your code Here
}

Form Level Event Handler In D365

"Form" methods, we can write  "Pre" and "Post" event handlers for the existing/new/override methods. For the Form > Init() methods we can write the "Pre" and "Post" event handler.
 Create a new class for event handler and add the "Pre" or "Post" methods

[PostHandlerFor(formStr(LedgerJournalTransCustPaym), formMethodStr(LedgerJournalTransCustPaym, init))]
public static void LedgerJournalTransCustPaym_Post_init(XppPrePostArgs args)
{
        info("Write Your Code Here");
     
}

Event Handler on form in datasource Level in D365

Form > Data source > Field level event handler methods can be written.

 form data source > fields level event > OnModified methods in the "LedgerJournalTransCustPaym" standard form.
1. Open the Form > LedgerJournalTransCustPaym > Data Source (LedgerJournalTrans) > Fields(UnitId) is the custom field added to LedgerJournalTrans - Events (expand the events node).
2. Right click on the OnModified > copy the event handler method. Below is the screenshot.

When modifying the custom field “UnitId” field in the form level, the Vend account (custom field added in the LedgerJournalTrans table) values needs to fetched basing on the UnitId modified.
In the same way basing on the requirement - “OnModified” event handler can be implemented on the form data source > field level event handler.

 /// <summary>
    /// Unitid  Onmodified event.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataFieldEventHandler(formDataFieldStr(LedgerJournalTransCustPaym, LedgerJournalTrans, UnitId), FormDataFieldEventType::Modified)]
    public static void UnitId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormDataSource          ledgerJournalTrans_ds   = sender.datasource();
        LedgerJournalTrans      ledgerJournalTrans      = ledgerJournalTrans_ds.cursor();
      
// Write Your Code Here.....................
    }

Sunday, November 11, 2018

How to send message to all online users in dynamics 365…

f you plan to make system down or maintain your system, You can send a message to all online users easily from LCS to save changes and save the business.

HOW..??

Just log in to your LCS account from here

lcs.dynamics.com/v2


assign the username and password and click next


select your project and select the specific environment


click Full Details and click maintain


click message online users and select the change type


You have two options::

1-- Broadcast a new message for downtime: to Send a message to all online users about planned downtime
2-Cancel message:: to cancel the active message




Set the time for this message (valid from ..to) and click POST



you see the message that will send to users
("This system will be temporarily unavailable starting at 2018-04-23 09:41 due to scheduled maintenance. Please save your changes and logout before the maintenance begins.")

Click YES
and Click OK

if you go to the browser and refresh the application page, you will receive the below message



To Cancel message, just select  cancel message type 

click delete on the right side

Thanks.

Tuesday, August 28, 2018

Deploying customization's into TEST environment Through LCS



First We have to Create deployment package , For Your Reference Please find below screen shot.




Select the packages or modals in  which your customization's are done .


and and give the package file location where you want to save it and click on create. 
It will create a deployment  package  on desired location.


Now login to LCS and go for Asset library in hamburger menu Like shown in figure.
and in software deployable package click on add and add here the deployment package which you have created earlier.


after that Open  TEST environment and click on maintain Tab and click on apply tab


After that select the package that you added in Software deployable packages  in asset library and click on Apply ,

after that system will take 30 to 60 min , if you faced any problem in process of deployment please download the log file that is  generated and check for the error in customization's 


Regards,
Venkatesh