Showing posts with label D365 FO. Show all posts
Showing posts with label D365 FO. Show all posts

Monday, 20 December 2021

D 365 FO code UserID to Employee details and Vice-versa

Hi all, 

The below block of code will give you the detail of employee by is userid and Vice-Versa, 


Public HCMWorker getEmployeeDetailsByUserID(UserID    _UserId)

{

        DirPersonUser   personUser;

        HcmWorker       worker;

        if (_userId == "")

    {

        _userId == curUserId()

    }

            select firstonly * from worker

                exists join personUser

                where worker.Person == personUser.PersonParty

                &&    personUser.User == _userId;

            return worker;

        }



Public DirPersonUser   getUserDetailsByPersonnelNo(PersonnelNum    _PersonnelNo)

{

        DirPersonUser   personUser;

        HcmWorker       worker;

select * from personUser

join worker

where worker.Person == personUser.PersonParty

&&  worker.PersonnelNumber == _PersonnelNo;

Return personUser.UserID;

}


Keeping DAXing ;/

Wednesday, 27 October 2021

D 365 FO Default password for MSSQL DB one box Environment

Hi all,

Below is the default password for the Database which we are using in the One Box Dev Environment.

       

        Username "axdbadmin" 

The default password of D365FO / AX7 VM Administrator is 'pass@word1'.

The default password of D365FO / AX7 VM Database Administrator is 'AOSWebSite@123'.

Keep DAXing :)

Tuesday, 5 October 2021

D 365 FO call the Other form by passing datasource as menu parameter

 Hi All,

in this post, we'll check how to call the Display menu Item or Form from the back end.

Step 1: Add the respective button in the existing form or new form, go to events, and copy the clicked event handler.

Sample code look alike

[FormControlEventHandler(formControlStr(SalesTable, Complete), FormControlEventType::Clicked)]

public static void Complete_OnClicked(FormControl sender, FormControlEventArgs e)

{

    // your Code       

}

now copy-paste or rewrite the below code according to your requirements.


[FormControlEventHandler(formControlStr(SalesTable, Complete), FormControlEventType::Clicked)]

public static void Complete_OnClicked(FormControl sender, FormControlEventArgs e)

{     

FormRun                             form                = sender.formRun();

        FormDataSource                      salesTable_ds        = form.dataSource(formDataSourceStr(SalesTable, SalesTable)) as FormDataSource;

   SalesTable                          salesTable = salesTable_ds.cursor();

        Args                                args;

        MenuFunction                        menuFunction;


        info(strFmt("%1",SalesStatus::None));

        if(salesTable.SalesStatus   == SalesStatus::None)

        {

            args.record(salesTable); // to send whole table as parameter

            args.caller(sender);

            menuFunction = new MenuFunction(menuItemDisplayStr(BER_CreateQuotationFromSalesOrder), MenuItemType::Display);

            menuFunction.run(args);

        }

        else

        {

            throw Error(strfmt('[LabelID]',salesTable.SalesStatus));

        }

}


Thanks

Keep Daxing :)

Monday, 4 October 2021

D 365 FO Form datasource Field Lookup in Extension Class

Hi all,

In this post, I'll explain to you how to define or add the lookup method for the Datasource field in the form by using the extension class and method.

Step 1: Go to the Field in the form for which you are willing to add the Custom lookup. Expand the Events Mouse right Click "Copy Event handled Method".

Step 2: Create a new Extension class or Paste the copied method in the new or existing extension class.

The sample code of copied method will look alike.

[FormControlEventHandler(formControlStr(SalesQuotationTable, Line_ItemId), FormControlEventType::Lookup)]
public static void Line_ItemId_OnLookup(FormControl sender, FormControlEventArgs e)
{       
}

Step 3: Copy / Type the below code  
[FormControlEventHandler(formControlStr(SalesQuotationTable, Line_ItemId), FormControlEventType::Lookup)]
public static void Line_ItemId_OnLookup(FormControl sender, FormControlEventArgs e)
{   
        Query                   query                   = new Query();
        QueryBuildDataSource    queryBuildDataSource;
        SysTableLookup          sysTableLookup;
        
        sysTableLookup = SysTableLookup::newParameters(tableNum([TableName]), sender);
        queryBuildDataSource = query.addDataSource(tableNum([TableName]));
        
        queryBuildDataSource.addRange(fieldNum([TableName], [FieldName for Filter])).value([Filter field value]);
        
        sysTableLookup.addLookupField(fieldNum([TableName], [FieldName to be selected and shown in lookup]), true);
        sysTableLookup.addLookupMethod(tableMethodStr([TableName], [FieldName to shown in Lookup]));

        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
}

Hope this post will help you to add the Customlookup in Datasource field.


Thanks,

Keep Daxing :)