Quantcast
Channel: Martin Dráb's Activities
Viewing all 17532 articles
Browse latest View live

Change Text IO file path to user downloads

$
0
0

Dears,

i am using Text IO to create TXT file, but what i want is to set the path to downloads, like the File::sendFileToUser() so the file can be downloaded on the local pc of the D365 user,

kindly provide me with other suggestions in order to achieve the above,


update purchLine record from purchLine using runnable class

$
0
0

Hi All,

I am trying update a field in a selected purchLine table with the following code, but it does not update the field even though the job is completed .

why is it like that?

    public static void main(Args _args)
    {
        PurchLine purchLine;
        ttsBegin;
        update_recordset purchLine
            setting my_CreatedBy = PurchTable::find(purchLine.PurchId).CreatedBy
            where purchLine.InventTransId == '1000035173';
        ttsCommit;
    }

Thank you. 

how to call another method in a 'try' block in case an exception is thrown inside a transaction

$
0
0

Hi All,

I would like to call a method in a 'try' block in case an exception is thrown inside a transaction.

my code can be simplified as follows:  

while (enumerator.moveNext())
{
	try
	{
		ttsbegin;
		...
		purchLine.update()
		ttscommit;
	}
	catch
	{
        infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());
        while(infoLogEnum.moveNext())
        {
            // currentException() returns you Exception enum and you can check if it is Exception::Error or Exception::Warning.
            switch (infoLogEnum.currentException())
            {
                case Exception::Warning:
                    info(strFmt("[Error] PO:%1 %2",purchLine.PurchId,infoLogEnum.currentMessage()));
                    break;
            }
        }
	}
}

I would like to include that call to another method within the tts begin- tts commit transaction block like below

while (enumerator.moveNext())
{
	try
	{
		ttsbegin;
		...
		purchLine.update()
		// here I would like to call another method before ttscommit 
		ttscommit;
	}
	catch
	{
        infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());
        while(infoLogEnum.moveNext())
        {
            // currentException() returns you Exception enum and you can check if it is Exception::Error or Exception::Warning.
            switch (infoLogEnum.currentException())
            {
                case Exception::Warning:
                    info(strFmt("[Error] PO:%1 %2",purchLine.PurchId,infoLogEnum.currentMessage()));
                    break;
            }
        }
	}
}

I tried to add that call right after purchline.update(), but then the infolog message is not shown to the user for a line with an error  in case multiple lines are selected for update.

Thank you. 

Electronic Reporting (ER) : How to add Record counter in Model ?

$
0
0

Hello All, 

As part of a new custom ER configuration I am creating in D365 Finance and Operations, there is a need for the output text file to have a field/column which has the record count.  

Header Record : the column will always be ‘000000001’.    

Line Records: similar column should begin with value of ‘000000002’ and should increment by 1 for each record.   

Example: 

000000002

000000003

Trailer Record : the value should just be continuation of increment of the last value in Line Records.  

Example: 
000000004


Is there an ER function that can achieve this?     COUNT function seems to only give the total count of records in data source.   While INDEX seems to return the content in a list, if the position number is passed into the INDEX function?  

Thank you,

Raghu

Throw error in jobs

$
0
0

Hi all, 

  I have attached a 2012 code(job) here where it seems to be they are running the report and saving its pdf file in local directory. But when I try to run this job in d365 it throws error.

When it reached controller.run() line it throws an error that file cannot be uploaded. How to achieve this in d365?

I have attached the 2012 code in below.

static void NAQ_DedutionReport_PCO(Args _args)
{
   Query query = new Query();
    int total;
    Name listRecid,month,years;
    RecId _recid;

  //  Year  years;
    SrsReportRunController controller;
    NSGLoans local,updateNsgLoan,countRecord, nsgLoansAll;
    EmpID _deductioEmp;
    SRSPrintDestinationSettings   settings;
    System.Byte[]    reportBytes = new System.Byte[0]();
    SRSProxy    srsProxy;
    SRSReportRunService    srsReportRunService = new SrsReportRunService();
    Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[]   parameterValueArray;
    Map  reportParametersMap;
    SRSReportExecutionInfo       executionInfo = new SRSReportExecutionInfo();
        Filename  filename;
 while select * from nsgLoansAll where nsgLoansAll.EmplId //== "13892"   //&&&& nsgLoansAll.IsGenerate == NoYes::No &&
                                      nsgLoansAll.LastMonth == 10 &&
                                      nsgLoansAll.LastYear == 2020

    {

    select count(RecId) from countRecord where countRecord.EmplId == nsgLoansAll.EmplId &&

                            countRecord.IsGenerate == NoYes::No &&
                                      countRecord.LastMonth == 10 &&
                                      countRecord.LastYear == 2020;

    {
        total = countRecord.RecId;
    }
    listRecid = "";
    if(total >1)
    {
         while select * from local where local.EmplId== nsgLoansAll.EmplId  &&

                                    local.IsGenerate == NoYes::No &&
                                      local.LastMonth == 10 &&
                                      local.LastYear == 2020

        {

            listRecid += strFmt(",%1",local.RecId);
            _deductioEmp = strFmt("%1",local.EmplId);
             month      = strFmt("%1",local.LastMonth);
             years      = strFmt("%1",local.LastYear);
        }
        listRecid = subStr(listRecid,2,60);
       //   info(listRecid);
       // if(local)
       //5637314832,5637319997
       //  _deductioEmp = countRecord.EmplId;
        controller = new SrsReportRunController();
        controller.parmReportName(ssrsReportStr(NQDeductionRpt, Report));
        //Get data contract instance.
        query = controller.parmReportContract().parmQueryContracts().lookup('Deduction_DynamicParameter');
        //Set parameter value;
        query.dataSourceNo(1).clearRanges();
        query.dataSourceNo(1).addRange(fieldNum(NSGLoans, RecId)).Value(strFmt("%1",listRecid));
        query.dataSourceNo(1).addRange(fieldNum(NSGLoans, LastMonth)).Value(strFmt("%1",month));
        query.dataSourceNo(1).addRange(fieldNum(NSGLoans, LastYear)).Value(strFmt("%1",years));

       if (!WinAPI::pathExists("E:\\Deduction\\"))
            WinAPI::createDirectoryPath("E:\\Deduction\\");

        filename =strfmt('E:\\Deduction\\%1%2%3%4%5%6%7%8',_deductioEmp,"-",month,"-",years,"-","D",".pdf");
        settings = controller.parmReportContract().parmPrintSettings();
        settings.printMediumType(SRSPrintMediumType::File);
        settings.fileFormat(SRSReportFileFormat::PDF);
        settings.overwriteFile(true);
        settings.fileName(filename);
        controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
        controller.parmReportContract().parmReportExecutionInfo(executionInfo);
        srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());
        srsReportRunService.preRunReport(controller.parmreportcontract());
        reportParametersMap =  srsReportRunService.createParamMapFromContract(controller.parmReportContract());
        parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
        controller.run();

        while select forUpdate updateNsgLoan where updateNsgLoan.EmplId == _deductioEmp
             && updateNsgLoan.LastMonth == str2int(month)  && updateNsgLoan.LastYear == str2int(years )
        {
            ttsBegin;
            updateNsgLoan.IsGenerate = NoYes::Yes;
            updateNsgLoan.update();
            ttsCommit;
        }

    }
    listRecid = "";
    if(countRecord && total == 1 )
    {
       select * from local where local.EmplId== nsgLoansAll.EmplId  &&
                                      local.IsGenerate == NoYes::No &&
                                      local.LastMonth == 10 &&
                                      local.LastYear == 2020;

            {

                listRecid += strFmt(",%1",local.RecId);
                _deductioEmp = strFmt("%1",local.EmplId);
                 month      = strFmt("%1",local.LastMonth);
                 years      = strFmt("%1",local.LastYear);
            }
        listRecid = subStr(listRecid,2,60);
        //   info(listRecid);
        // if(local)
        //5637314832,5637319997

        //  _deductioEmp = countRecord.EmplId;
        controller = new SrsReportRunController();
        controller.parmReportName(ssrsReportStr(NQDeductionRpt, Report));
        //Get data contract instance.
        query = controller.parmReportContract().parmQueryContracts().lookup('Deduction_DynamicParameter');
        //Set parameter value;
        query.dataSourceNo(1).clearRanges();
        query.dataSourceNo(1).addRange(fieldNum(NSGLoans, RecId)).Value(strFmt("%1",listRecid));
        query.dataSourceNo(1).addRange(fieldNum(NSGLoans, LastMonth)).Value(strFmt("%1",month));
        query.dataSourceNo(1).addRange(fieldNum(NSGLoans, LastYear)).Value(strFmt("%1",years));

        if (!WinAPI::pathExists("E:\\Deduction\\"))
            WinAPI::createDirectoryPath("E:\\Deduction\\");

        filename =strfmt('E:\\Deduction\\%1%2%3%4%5%6%7%8',_deductioEmp,"-",month,"-",years,"-","D",".pdf");
        settings = controller.parmReportContract().parmPrintSettings();
        settings.printMediumType(SRSPrintMediumType::File);
        settings.fileFormat(SRSReportFileFormat::PDF);
        settings.overwriteFile(true);
        settings.fileName(filename);
        controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
        controller.parmReportContract().parmReportExecutionInfo(executionInfo);
        srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());
        srsReportRunService.preRunReport(controller.parmreportcontract());
        reportParametersMap =  srsReportRunService.createParamMapFromContract(controller.parmReportContract());
        parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
        controller.run();

         select forUpdate updateNsgLoan where updateNsgLoan.EmplId == local.EmplId &&
            updateNsgLoan.LastMonth == str2int(month)  && updateNsgLoan.LastYear == str2int(years);
        {
            ttsBegin;
            updateNsgLoan.IsGenerate = NoYes::Yes;
            updateNsgLoan.update();
            ttsCommit;
        }
      }


    }


}

event handler to clear the concept

$
0
0

FormDataSourceEventHandler(formDataSourceStr(Agent, Estate), FormDataSourceEventType::Activated)]
public static void Agent_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun element = sender.formRun();
FormControl agentGroup = element.design(0).controlName("Hello India");
FormControl insAgent = element.design(0).controlName("Getting the Real estate market");
if(agentGroup.valueStr() == RealParameters::find().aisInsuranceVendorGroup)
insAgent.enabled(true);
else
insAgent.enabled(false);

}

Can someone make me this to understand the code of event handler?

X++ Post Item Requirements Packing Slip From Service Order

$
0
0

Hi,

I have a requirement to post packing slip from service order.

I was referring to this link Posting project item requirement picking list in X++ - Microsoft Dynamics AX Forum Community Forum

So I added a button in Service order form and try to run the logic on button click event:

[FormControlEventHandler(formControlStr(SMAServiceOrderTable, PostPackingSlip), FormControlEventType::Clicked)]
public static void PostPackingSlip_OnClicked(FormControl sender, FormControlEventArgs e)
{
    FormDataSource fds = sender.formRun().dataSource(tableStr(SMAServiceOrderTable));
    SMAServiceOrderTable smaServiceOrderTable = fds.cursor();
    SalesLine salesLine, _salesLine;
    CustPackingSlipJour custPackingSlipJour;
    SalesFormLetter salesFormLetter;
    SysQueryRun queryRun;
    Query query;
    select salesLine where salesLine.ServiceOrderId == smaServiceOrderTable.ServiceOrderId&& (salesLine.SalesStatus == SalesStatus::None || salesLine.SalesStatus == SalesStatus::Backorder);
    if(salesLine)
    {
        salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
        query = new Query(QueryStr(SalesUpdate));
        query.dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable, SalesId)).value(salesLine.SalesId);
        query.dataSourceTable(tablenum(SalesLine)).addRange(fieldnum(SalesLine, ServiceOrderId)).value(salesLine.ServiceOrderId);
        query.dataSourceTable(tablenum(SalesLine)).addRange(fieldnum(SalesLine, SalesStatus)).value(enum2Str(SalesStatus::Backorder));
        queryRun = new SysQueryRun(query);
        salesFormLetter.chooseLinesQuery(queryRun);
        salesFormLetter.chooseLines(false,true);
        salesFormLetter.transDate(systemdateget());
        salesFormLetter.specQty(SalesUpdate::All);
        salesFormLetter.printFormLetter(false);
        salesFormLetter.reArrangeNow(true);
        Info(salesFormLetter.parmId());
        salesFormLetter.run();
        if (salesFormLetter.parmJournalRecord().TableId == tableNum(CustPackingSlipJour))
        {
            custPackingSlipJour = salesFormLetter.parmJournalRecord();
            info(strFmt('Sales Order #:%1 has been successfully posted and Packing Slip #:%2 is created!',
                custPackingSlipJour.SalesId, custPackingSlipJour.PackingSlipId));
        }
    }
    else
    {
        warning('Item requirements not found.');
    }
}

salesFormLetter.parmId() returns value but when I check related parmId in SalesParmTable and SalesParmLine, these two tables are somehow empty.

Hence, the packing slip is not posted even though the QueryRun returns the correct SalesLine records.

What am I missing here? Thank you.

How to call API for exchange rate configuration

$
0
0

Hi All,

In our implementation, we are using new vendor for exchange rates apart from Microsoft provided vendors for exchange rate.

how to get exchange rate API do we need to customization to achieve this . please help out if any one done.

Thanks in advance.

Regards,

Gupta


Trying to create new dimension value

$
0
0

Hi All

I am trying to create a new dimension value in one of our financial dimensions we call Location.

When I go to GL>CofA>Dimesnions>financial DImensions click on the dimension and go to Dimension values it shows a list of our current locations.

I want to create a new location, but the "New" button (along with delete and translations button) is greyed out. Why?

infolog buffer should not reset in try...catch statement per iteration

$
0
0

Hi All,

I have an issue that the infolog buffer is totally reset so that error details already cumulated for records processed earlier (purchLine.update()) via a set enumerator are lost after iterating next records which confirm PurchTable records not only updating line details.  If I dont want to lose those error details stacked but show these to users, what shoud we do? 

Thank you.

Data Entity Export to excel Error

$
0
0

Data Entity Export to excel Error

The formatter throw an error while trying to desearlize the message 

Getting path errors in Project

$
0
0

i have build a project where the tabs of concern path is showing that it cannot be empty but according that sequence ,it is already in  build.

Need Solution for it please?

RecordInsertList and insert_recordset , Is there any difference?

$
0
0

Hi,

RecordInsertList and insert_recordset , Is there any difference?

Which one mostly preferred to use?

Kindly give me more shed on this 

Trigger for product export

$
0
0

Hi All,

How to set the trigger for exporting the product and product master.

Which is the best option, how to handle it without using the button control event.

Just assume that I create a product in D365 for some reason I am not able to give some information at that time, it inserts the record in the table. Again, I update some information with some fields and again it sends the record.

In the journal line, the control is in the post button, like the same way do we have any functionality for exporting the product and product master.

Can we make use of the validate button in the product master

Please suggest this.

How to write trace (logs) for our code in X++ ?

$
0
0

Hello,

Can anyone suggest the best practice to write trace (logs) for our code in X++. So in case of any issues we can collect that logs and find where the issue is. 

I have gone through Trace functionality of D365 F&O. where we can analyze that trace file in trace parser to collect performance related information but I think we can not write our logs in that. right ? let me know if I am missing anything here.


Form field relation data link

$
0
0

Hey team,

I was working on a form "EssPersonalDetails" form which is simple list w/Standard tabs from There is something which I don't know as I'm working on this type of  form for the first time. There is a field named "link" and "Formfieldrelationdatalink" field in the form below each tab. Please can you tell me. What is it used for? or some blogs which I can refer to in this case because on the front end I see a grid but that grid is not seen on the form.

Change Text IO file path to user downloads

$
0
0

Dears,

i am using Text IO to create TXT file, but what i want is to set the path to downloads, like the File::sendFileToUser() so the file can be downloaded on the local pc of the D365 user,

kindly provide me with other suggestions in order to achieve the above,

How to update CreatedBy or ModifiedBy field

$
0
0

Hello guys,

I have a web service that creates some records and the CreatedBy field of a table is populated using the admin user since there is no user interaction.

I'm already sending the CreatedBy value on the request, but I want to update the CreatedBy field on the table.

However, this is a system field and I cannot update it. There is any way to override it?
When I try to write x++ code it shows "The field CreatedBy is read only. A value cannot be assigned to it"

Thanks,

LCS error Microsoft.Dynamics.Ax.MSIL.Interop.GetManagedCallStack

$
0
0

Hi,

I have an issues in Test environment deployed on LCS.

Recently we are facing an issue in Test envt where we are not able to add records from one grid to other .

So on clicking the add (arrow) button as shown below  I get the error " Object reference not set to an instance of an object".

However we dont have this error in any of your environment which are of same versions PU 36.

I checked in LCS and found the below stact and It is very difficult to figure it out what is the issue.

Can someone please guide.

at [aoskernel.dll]Microsoft.Dynamics.Ax.MSIL.Interop.GetManagedCallStack(basic_string\,std::allocator >* )at [aoskernel.dll]Microsoft.Dynamics.Ax.Services.AOSAppDomainHelper.callGetManagedCallStack(basic_string\,std::allocator >* )at callGetManagedCallStack(basic_string\,std::allocator >* )at cqlClass.callEx(cqlClass* , Char* , interpret* )at cqlClass.callEx(cqlClass* , Char* , interpret* )at [aoskernel.dll]Microsoft.Dynamics.Ax.MSIL.cqlClassIL.Call(IntPtr c, String methodName, Object[] parameters, Type[] types, Object[] varargs, Type[] varargsTypes)at [Microsoft.Dynamics.AX.Server.Core.dll]Microsoft.Dynamics.Ax.Xpp.XppObjectBase.Call(String methodName, Object[] parameters, Type[] types, Object[] varargs)at [Microsoft.Dynamics.Ax.Xpp.Support.dll]Dynamics.AX.Application.xInfo.addException(String _string, String _stackTrace)at [Dynamics.AX.ApplicationPlatform.dll]Dynamics.AX.Application.Info.`addException(String _txt, String _stackTrace)at [Dynamics.AX.ApplicationPlatform.dll]Dynamics.AX.Application.Info.addException(String _txt, String _stackTrace)at Info::addException(Object , Object[] , Boolean& )at [Microsoft.Dynamics.Ax.Xpp.Support.dll]Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeInstanceCall(Object instance, String MethodName, Object[] parameters)at [Microsoft.Dynamics.AX.Server.Core.dll]Microsoft.Dynamics.Ax.Xpp.XppException.SetInfologMessage(ExceptionKind exceptionKind, String text, String stackTrace)at [Microsoft.Dynamics.AX.Server.Core.dll]Microsoft.Dynamics.Ax.Xpp.XppException.Make(Exception ex)at [Microsoft.Dynamics.Ax.Xpp.Support.dll]Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeInstanceCall(Object instance, String MethodName, Object[] parameters)at [Microsoft.Dynamics.AX.FormsEngine.dll]Microsoft.Dynamics.Ax.Xpp.FormNestedElementsCoCSubscriptionsManager.MakeInstanceCall(Object instance, String methodName, String nestedElementName, String rootName, Object[] parameters)at [Microsoft.Dynamics.Ax.Xpp.Support.dll]Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.KernelToXppInstanceCallCoC(Object instance, String methodName, String nestedElementName, String rootName, Object[] parameters)at [aoskernel.dll]Microsoft.Dynamics.Ax.MSIL.cqlClassIL.InvokeInstanceCallHandlerCoC(Object instance, String MethodName, String NestedElementName, String RootName, Object[] parameters)at callILClassMethodCoC(interpret* ip, Char* method, Char* nestedConceptName, Char* rootName, UInt32 chdl, cqlClass* c)at [aoskernel.dll]Microsoft.Dynamics.Client.ServerForm.Interactions.InteractionHandler.InvokeCommand(CommandInteraction interaction, CommandCallbackInteraction& result)at [aoskernel.dll]Microsoft.Dynamics.Client.ServerForm.Interactions.InteractionHandler.HandleCommandInteraction(CommandInteraction interaction, List`1 outboundInteractions)at [aoskernel.dll]Microsoft.Dynamics.Client.ServerForm.Interactions.InteractionHandler.HandleInteractions(IInteractionChannel interactionChannel)at [aoskernel.dll]Microsoft.Dynamics.Client.ServerForm.Interactions.InteractionManager.ProcessMessages(Object stateinfo)at [mscorlib.dll]System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)at [mscorlib.dll]System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)at [mscorlib.dll]System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()at [mscorlib.dll]System.Threading.ThreadPoolWorkQueue.Dispatch()

Thanks,

Vikas Mehta

Create Reference Group on Form Extension D365

$
0
0

Dear Experts,

i am trying to create a new reference group on the EcoResProductCreate Form similar to the retail category reference group, but this reference group will show the procurement category dropdown in the same way of the retail category ( hierarchy).

your help is highly appreciated.

Viewing all 17532 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>