Posts

Showing posts from October, 2024

Run some code as different user rights in D365 X++

  we can define the user in parameter form where we define the user whose rights we want to use. otherwise we can run it as an admin public static void  main(Args _args)     {                  FormRun fr   = _args.caller();         FormDataSource fds;                          RunAsPermission perm;         UserId runAsUser;         SysUserInfo userInfo;         if(CustomParrameter::Find().UserId)         {         userInfo = SysUserInfo::find(CustomParrameter::Find().UserId);         }else         {             userInfo = SysUserInfo::find("Admin");         }         runAsUser = userInfo.Id;         perm ...

To find Customer Registration Id

 public  TaxRegistrationNumber getCustVATNo(CustTable _custTable ,str _type)     {           TaxRegistration                             taxRegistration;         DirPartyLocation                            partyLocation;         TaxRegistrationTypeApplicabilityRule        taxRegistrationRule;         TaxRegistrationType                         taxRegistrationType;       ...

Importing Database from Uat to Dev Enviroment in D365 FO

Image
.. First Move Uat Database From LCS than Once Database Exported download it from asset library. Once downloaded Run this command in SSMS ALTER DATABASE AxDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE AxDB MODIFY NAME = AxDBOrign GO ALTER DATABASE AxDBOrign SET MULTI_USER; GO After that change the path of your file and run this command in CMD SqlPackage.exe /a:import /sf:D:\Exportedbacpac\my.bacpac /tsn:localhost /tdn:AxDB /p:CommandTimeout=30000  /TargetTrustServerCertificate:True Regards  Muhammad Farraz email: farazjaved01@gmail.com

Copy Attachment From one Record to another in x++

   private void copyAttachments(RecId _copyFromRecid,TableId _copyFromTableId, RecId _copyToRecid,TableId _copyToTableId)     {         DocuRef copyfromDocuRef;         DocuRef ProjTableDocuRef;         //Search if exists an attachment          while select  copyfromDocuRef             where copyfromDocuRef.RefTableId == _copyFromTableId             &&   copyfromDocuRef.RefRecId == _copyFromRecid         {             //Copy attachment              DocuRef::createFromDocuRef(copyfromDocuRef,_copyToRecid , _copyToTableId);         }     } Regards  Muhammad Farraz email: farazjaved01@gmail.com