Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Sunday, August 29, 2021

SQL error description: [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot drop the index [table Name.Index] because it does not exist or you do not have permission.

 Hi,

Error: 

SQL error description: [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot drop the index 'WORKFLOWTRACKINGTABLE.IX_WORKFLOWTRACKINGTABLE_WORKFLOWTRACKINGSTATUSTABLE_PARTITION_TRACKINGCONTEXT_TRACKINGT', because it does not exist or you do not have permission.

Impact:

Results in synhronization failure.

Resolution :

1. Table a backup of the DB.

2. Delete the particular index from SQL side and synchronize the respective table in application.


Regards,

Sunday, August 22, 2021

How to add ranges in SSRS in design level

 Hi,

In the Tablix property of the grid we add the filter in any rages.

NOTE: 

1. All the operator are common and except  < > . This < > for != Not equals to ranges.

2. We cant add multiple ranges of same filed in same expression values whereas we need to create n number of filters against the expression to add ranges accordingly.

3. Working on Row visibiliy expression is not recomended to achiew this ranges.

4. To have AND condition in the value needs to add between Value1 and Value2



Regards,

Wednesday, July 14, 2021

Alternative row colors with different scope in SSRS

 Hi,


Alternative colors without any scope or condiction.

=iif(RowNumber(Nothing) Mod 2, "#ffffff", "#f0f0f0") 


Alternative colors with scope or condiction.

=IIF(RunningValue(Fields!CustId.Value, CountDistinct, Nothing) MOD 2 = 1, "#ffffff", "#f0f0f0") 


We can display alternative colors based on distinct running values or by parent groups or specific condition like

=IIF(Fields!Amount.Value > 35000 , "#ffffff", "#f0f0f0") 


Even we can achive group with in group cases and Matrix cases by selecting particular cells.


Regards

Wednesday, July 7, 2021

Jobs to export CSV from D365

 Hi,


class DpayExportCSV

{        

     /// <summary>

    /// Runs the class with the specified arguments.

    /// </summary>

    /// <param name = "_args">The specified arguments.</param>

    public static void main(Args _args)

    {

        CommaStreamIo commaStreamIo = CommaStreamIo::constructForWrite();

        SalesTable       SalesTable;

        SalesLine       SalesLine;

        FilePath  tempDir = "C:\\Temp\\SalesTable.csv";

       // #define.filename(@'C:\Temp\SalesTable.csv')

        ;

 

        const str fileName = 'SalesTable.csv';

        commaStreamIo.writeExp(['Level', 'SalesId', 'CustAccount','DlvTerm']); // Header

        while select * from SalesTable

        {

            commaStreamIo.writeExp(['OH', SalesTable.SalesId, SalesTable.CustAccount,SalesTable.DlvTerm]);

            while select SalesLine where SalesLine.SalesId ==  SalesTable.SalesId

            {

                commaStreamIo.writeExp(['OL', SalesLine.ItemId, SalesLine.SalesQty, SalesLine.InventDimId]);

                //// You may further add your componbenets table below to this within this loop

            }

        }

        System.IO.Stream stream = commaStreamIo.getStream();

        stream.Position = 0;

 

        FileUploadTemporaryStorageResult result = File::SendFileToTempStore_GetResult(stream, fileName);

       // System.IO.File::Move(result.getFileName(),tempDir);

        System.IO.StreamReader sReader = new System.IO.StreamReader(result.openResult());


        // Set file contentn string

        str  fileContent = sReader.ReadToEnd();

        //System.IO.File::Move(fileContent,tempDir);

        // Save file

        File::SendStringAsFileToUser(fileContent, tempDir);

        

      //  File::SendFileToTempStore(stream,"\\C:\\Temp\\SalesTable.csv");

        info(result.getDownloadUrl());

        Message::Add(MessageSeverity::Informational, result.getDownloadUrl());

        

    }

}


Regards,

REST Vs SOAP in AX 2012/D365

Hi,

The integration between 2 application/platform to perform the action of integration is termed as API (Application programming interface).

Integration will be in the forms of URL that contains service address with hosted location (server).

REST and SOAP are the 2 API services.

The REST and SOAP has its own unique properties and behaviour.

SOAP will support only XML structure of data format.

REST supports all the structure of data format viz JSON.

WSDL (Web Services Description Language) based call services are SOAP API.

AX 2012 cannot be integrated directly from any API, for that we have to create serviceReference in Visual Studio and to be deploy the project in AOT to consume the functions and object present in that services.

AX2012 supports only SOAP web services.

 D365 can be integrated by custom web services or ODATA. It creates 2 endpoints one for REST and other of SOAP.

Regards,

Thursday, March 25, 2021

Generate script to recreate the DDL with data and without data

Hi,

To recreate the DDL please follow below procedure


If you would like to generate the script with data please select Advance in that Advanced Scripting Option please select the type of data to script : Schema and data



on Successful finish of this wizard will open a script window and we can save or share to other instance to regenerate the DDL

Regards


Wednesday, March 24, 2021

Adding admin user in to D365 instance

 Hi,

There are 2 ways to add admin user in to an instance.

1. System Administrator \ User \ Import from Acive Directory.

2. Using admin user provisioning tool.


Using admin user provisioning tool.

1. Run the AdminUserProvisioning shortcut placed in desktop of AOS server.

2. Enter the email address of the account has AAD ( Azure Active directory) and Submit.



Note: Shortcut is not available in desktop, please check below URL

https://alfasith.blogspot.com/2021/03/how-to-add-dynamics-365-admin-user.html


Regards

How to add Dynamics 365 admin user provisioning tool in desktop

 Hi,


During VM creaction, we may missed out to add the shortcut of user provisioning tool in desktop, for that we have to manually create the shortcut from the installed exe run file.

C:\AOSService\PackagesLocalDirectory\bin\AdminUserProvisioning.exe

Add shortcut to desktop for selected file.

Regards,




Tuesday, March 9, 2021

Extend / Customize standard CanSubmitToWorkflow in D365

Hi,


We cant override CanSubmitToWorkflow to return our boolean on any eventHandler's return like eventHandler of ValideWrite(). To achiew we have to set the args of CanSubmitToWorkflow() to be decided by our code.

[PostHandlerFor(formStr(CustTable), formMethodStr(CustTable, canSubmitToWorkflow))]

    public static void CustTable_Post_canSubmitToWorkflow(XppPrePostArgs args)

    {

        FormRun     form = args.getThis();

        FormDataSource      custTable_ds = form.dataSource(formDataSourceStr(custTable,CustTable)) as FormDataSource;

        custTable           custTable    = custTable_ds.cursor();

        if (custTable.RecId && custTable.DocumentStatus == DocumentStatus::NotSubmitted)

        {

            args.setReturnValue(true);       

        }

        else

        {

            args.setReturnValue(false);

        }

    }


Regards,

Monday, February 22, 2021

How to achieve table relation in SQL without primary index 1:n

HI,

Select particular parent table (master table) db.table.
1. Right click select design

2. Select the respective field where we have to achieve unique index but not primary.
Right click on that filed select Indexs/keys...



3. Add the select the column to from that list and please make sure you change the property to YES in isUnique.


4. Save and select the design of transaction table where we try to achive Foreign key.
Right click on that particular filed and choose Relationships..


5. Add the relationship by select the tables and columns specifics.




Regards,

 

Thursday, February 18, 2021

RandomNumbers In AX /D365

 Hi,


static void CreateRandomNumbersInAX(Args _args)

{

    RandomGenerate randomGenerate;

    ;

    randomGenerate = RandomGenerate::construct();

    randomGenerate.parmSeed(new Random().nextInt());

    info(int2str(RandomGenerate.randomInt(0,2147483647)));   //RandomInt(RangeFrom,RangeTo)

    //Note: Range from should be more than natural number 0 and more.

 

}

OutPut

1786303728


To understand the formula behind this random number please refer randomInt() in RandomGenerate class.

The formula in randomNumber generation is not similar to library function of dotnet.

Note: We cannot treat this randomGenerated Values as primary key, this may repeat with same range.

Regards,



GUID in AX 2012 / D365

 //< What is GUID>

// GUID 16 bit large range of alphanumeric similar to RecID to treat as primary key of a table.

static void CreateGUIDInAX(Args _args)

    str 60 strGuid;

    ;

    info(Winapi::createGUID());         // Creates GUID and removes the braces

    info(guid2str(newGuid()));           // Creates GUID with braces

    //NOTE: GUID is not a string so we needs to convert GUID to str for using...

}

Output:

C2B4FEBF-2393-43BB-9EA5-B173B907CA2A

{BAD14349-5837-4AC3-9B9B-9D6FB0F86BEC}

note: Your output and mine needs to be same.


Regards.

Monday, January 11, 2021

Round the decimals (upper / lower) in AX 2012 / D365

 Hi,


static void AlfRound(Args _args)

{

    Amount  amount = 5578.59;

    info(strfmt("Amount %1", amount)); // Printing the original values

    info(strfmt("Round,1  - %1", round(amount,1))); // This performs standard operation of round and removes the decimal.

    info(strfmt("roundDown,1 - %1", roundDown(amount,1)));  //Always round by down with ones position, if you make 100 then output will be 5,500.00

    info(strfmt("roundDownDec,1 - %1", roundDownDec(amount,1))); // Down rounding only the decimal values

    info(strfmt("roundUpDec,1 - %1", roundUpDec(amount,1))); //Up rounding only the decimal values

    info(strfmt("roundup,1 - %1", roundup(amount,1))); //Always round by down with ones position, if you make 100 then output will be 5,600.00

    info(strfmt("roundUp(roundUp,1) - %1", roundUp(roundup(amount,1),1))); // Roud the rounded amount will not make any changes in the rounded amount.

    info(strfmt("decround,1 - %1", decround(amount,1))); // It performs the standard operation of round in decimal 

}


Regards,

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...