Monday, March 18, 2019

Delete a Model in D365 Finance and Operations.

https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-tools/models

Deleting a model

On a development or test environment, follow these steps to delete a model.
The following steps assume the local model store folder is C:\AOSService\PackagesLocalDirectory and your model is named MyModel1.
If your model belongs to its own package (For example: An extension package with no other models in the package):
  1. Stop the following services: The AOS web service and the Batch Management Service
  2. Delete the package folder C:\AOSService\PackagesLocalDirectory\MyModel1
  3. Restart the services from step 1
  4. If Visual Studio is running, refresh your models (Visual Studio > Dynamics 365 > Model management > Refresh models)
  5. In Visual Studio, perform a full database synchronization (Visual Studio > Dynamics 365 > Synchronize database...)
If your model belongs to a package with multiple models (For example, MyModel1 overlays Application Suite):
  1. Stop the following services: The AOS web service and the Batch Management Service
  2. Delete the model folder C:\AOSService\PackagesLocalDirectory<PackageName>\MyModel1 (In this example PackageName=ApplicationSuite)
  3. Restart the services from step 1
  4. In Visual Studio, refresh your models (Visual Studio > Dynamics 365 > Model management > Refresh models)
  5. In Visual Studio, build the package that the deleted models belonged to (Visual Studio > Dynamics 365 > Build models...)
  6. In Visual Studio, perform a full database synchronization (Visual Studio > Dynamics 365 > Synchronize database...)

Friday, May 12, 2017

Joins In AX


Main table records => 3
Child table records => 3

Matched reocords in child table => 3 (2 duplicate and 1 is unique)

Inner join => matched records in Parent table (P => 3, C => 3)

Outer Join => Matched records in Parent table and Unmatched records display in parent datasource only, show null values in child datasource unmatched records.

Exists Join => display matched records in parent table in child datasource shows null values.


Not Exists Join => display only in parent table records those are not existing in the child table.

Monday, August 10, 2015

Send Email Through AX 2012

static void SendTextMail(Args _args)
{
    System.Net.Mail.MailMessage             mailMessage;
    System.Net.Mail.SmtpClient              myMail;
    System.Net.Mail.MailAddressCollection   mailcoll;
    System.Net.Mail.MailAddress             mailFrom;
    System.Net.Mail.MailAddress             mailTo;
    System.Net.Mail.MailAddress             mailCC;
    str                                     receiverMailAddress;
    str                                     mailBody;
    str                                     smtpServer;
    str                                     mailSubject;
    str                                     CcMailAddress;
    int                                     SMTPPort;
    #File
    str                                     mail;
    str                                     pwd;

    Dialog dialog = new Dialog('Email');
    Dialogfield     person, emailSubject, emailBody;
    HcmWorker       hcmWorker;
    UserInfo        userInfo;
    DirPersonUser   dirPersonUser;
    SysUserInfo     sysUserInfo;
    SysEmailParameters parameters;
    System.Exception e;

    // dialog field to select user to whom email will be send
    person          = dialog.addField(extendedTypeStr(HcmWorkerRecId ), 'Person :' );
    emailSubject    = dialog.addField(extendedTypeStr(Description), 'Subject :' );      // Email Subject
    emailBody       = dialog.addField(extendedTypeStr(Notes), 'Body :' );               // Email Body

    if(dialog.run())
    {
        parameters = SysEmailParameters::find();   // Find values from Email Parameters

        new InteropPermission(InteropKind::ClrInterop).assert();

        // gets HcmWorker record based on person selected from user dialog
        hcmWorker = hcmWorker::find(person.value());

        if(!hcmWorker.RecId)   // Verify either user exist or not
        {
            throw error('User not found');
        }

        select firstOnly dirPersonUser
            join userInfo
                where dirPersonUser.PersonParty == DirPartyTable::findByName(hcmWorker.name()).RecId &&
                 userInfo.id == dirPersonUser.User;

        select firstOnly sysUserInfo
            where sysUserInfo.Id == userInfo.id;      // Retrieve user info record for selected user

        mailSubject         = emailSubject.value();
        mailFrom            = new  System.Net.Mail.MailAddress(parameters.SMTPUserName ,"Name");
        mailTo              = new  System.Net.Mail.MailAddress("ayyappa.kambhampati@gmail.com");
        //mailTo            = new  System.Net.Mail.MailAddress("test1@gmail.com");
        //mailCC            = new  System.Net.Mail.MailAddress("test2@gmail.com";
        mailcoll            = new  System.Net.Mail.MailAddressCollection();
        mailBody            = emailBody.value();

        try
        {
            // using the SMTP server ip //setup in email Parameters
            smtpServer          = SysEmaiLParameters::find(false).SMTPRelayServerName;
            mailMessage         = new System.Net.Mail.MailMessage(mailFrom,mailTo);
            mailmessage.set_Subject(mailSubject);
            mailmessage.set_Body(mailBody);

            SMTPPort            = SysEmaiLParameters::find(false).SMTPPortNumber;
            myMail              = new System.Net.Mail.SmtpClient(smtpServer, SMTPPort);

           // For SSL enabled mail servers. Ex: gmail, smtp.gmail.com, port 465 or 587
            myMail.set_EnableSsl(true);

            pwd = SysEmaiLParameters::password();

            mymail.set_Credentials(New System.Net.NetworkCredential(parameters.SMTPUserName, pwd));

            mymail.Send(mailmessage);
        }
        catch(Exception::CLRError)
        {

        e = ClrInterop::getLastException();

        while (e)
        {
            info(e.get_Message());
            e = e.get_InnerException();
        }
        mailMessage.Dispose();
        CodeAccessPermission::revertAssert();
        }
    }
}

Friday, June 19, 2015

Add Container Values In Ax 2012


static void containerEx(Args _args)
{
    container con = [1,2,10];
    int i=0,j,k;
   
    for( i=1;i<=conLen(con);i++)
    {
        j += conpeek(con,i); // Adding Container Values (Appending)
    }
    info(strFmt("%1",j));
}

Saturday, June 6, 2015

Filter in List Page

public void initializeQuery(Query _query)
{
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    super(_query);
      qbr =_query.dataSourceTable(tablenum(CustTable)).addRange(fieldnum(CustTable,CustGroup));
   //qbr.value(queryvalue(HcmWorker::findByPerson(DirPersonUser::find(curUserId()).PersonParty).PersonnelNumber));
    qbr.value("10");

}