Wednesday, 29 September 2021

AX2012 /AX365 Filter the financial dimension for a security role

 One of the most common needs to restrict the user for specific financial dimension values

create a new query and add a table DimensionFinancialTag as the image below


browse the table to get the category 


after we get the category id to add range into the query as the first step like this



You should set the value as the expression below

((FinancialTagCategory==5637144577)&&(Value>="10000"))&&(Value<="19999"))


then create a new policy and assign the query to the policy and assign also the Security role as below


and make sure that to set the property of the contained table to yes 


and Happy Daxing 






Wednesday, 8 September 2021

MPOS DA3001 - A connectivity error has occurred and your device can't connect to the server. AX365 Retail

 mpos DA3001 - A connectivity error has occurred and your device can't connect to the server. This may be due to one or more of the following reasons. Contact your system administrator. The server URL typed may have some issues, check for typo errors or if it matches the HTTP protocol of the server. Server can't be reached because it is offline; The Application pool has stopped. Restart the pool and try again; The Server host name can't be resolved because the DNS can't be reached; Server is actively refusing the connection because the port you are using is not allowed through the firewall; The local system doesn't have network connectivity; The local system firewall is blocking outgoing connections. Add a firewall exception for the application. Server is not from the same origin of local system so the request is blocked by Cross-Origin Resource Sharing (CORS)

Solution 

first, check the retail server health by the below link 

https://usnconeboxax1ret.cloud.onebox.dynamics.com/healthcheck?testname=ping

the result should be like this 

PING SMOKE TEST SUMMARY RESULTS


TEST NAMEDATARESULT TEXTTEST STATUSTEST SEVERITY
PingDBCheckSuccessSucceededNormal
PingRealtimeServiceCheckSuccessSucceededNormal

Second

To add Dynamics 365 Modern POS to the loopback exemption list. Run Command Prompt as Administrator and copy-paste the below code. Note: Based on my check on multiple machines, the container name for MPOS is the same across all machines

CheckNetIsolation.exe LoopbackExempt –a -n=microsoft.dynamics.retail.pos_8wekyb3d8bbwe
For more details refer the link belowOriginal reference


Tuesday, 17 August 2021

AX 2012 X++ Upload product image from code

 static void Job7(Args _args)

{

 DocuRef docuRef;

DocuValue docuValue;

InventTable inventTable;

EcoResProductImage ecoResProductImage;


System.String[] fileNames;

int fileCount, i;


str fileName, trimmedFileName, fileNameWithExt;

BinData binData;


binData = new BinData();

//fileNames = System.IO.Directory::GetFiles(strFmt(@"%1", StringFilePath.valueStr()));

fileNames = System.IO.Directory::GetFiles(@"C:\hh");



fileCount = fileNames.get_Length();


for (i=0; i<fileCount; i++)

{

fileName = fileNames.GetValue(i);



trimmedFileName = substr(fileName, strscan(fileName, '\\', strlen(fileName), -strlen(fileName))+ 1, strlen(fileName));

fileNameWithExt = trimmedFileName;

if (trimmedFileName)

{

// Assuming file extension is always .jpg, removing it

trimmedFileName = strreplace(trimmedFileName, ".jpg", "");

}

// assuming image name matches item name in AX

inventTable = InventTable::find(trimmedFileName);


if (inventTable)

{

binData.loadFile(fileName);


//docuValue.FileName = trimmedFileName;

docuValue.Name = trimmedFileName;


docuValue.FileType = "jpg";

docuValue.OriginalFileName = fileNameWithExt;

docuValue.File = binData.getData();

docuValue.insert();


docuRef.ValueRecId = docuValue.RecId;

docuRef.RefTableId = tableNum(InventTable);

docuRef.RefRecId = inventTable.RecId;

//docuRef.RefRecord = inventTable.RecId;

docuRef.RefCompanyId = curext();

docuRef.Name = trimmedFileName;

docuRef.TypeId = "File";

docuRef.insert();


ecoResProductImage.clear();

ecoResProductImage.DefaultImage = true;

ecoResProductImage.FileName = fileNameWithExt;

ecoResProductImage.ImageFormat = "jpg";

ecoResProductImage.RefRecId = docuRef.RecId;

ecoResProductImage.RefRecord = docuRef.RefRecId;

ecoResProductImage.Usage = 0; // Base Enum: 0=External, 1=Internal

ecoResProductImage.insert();


}

}

}


Tuesday, 27 July 2021

AX365 X++ add a new dimension value into financial dimensions

 


      DimensionValueContract _contract = new DimensionValueContract();

        _contract.parmDimensionAttribute('Dimension name');

        _contract.parmValue('Dimension value');

        _contract.parmDescription('Dimension Description');

      

        DimensionValueService _service = new DimensionValueService();

        _service.createDimensionValue(_contract);

Tuesday, 29 June 2021

AX365 create a notification to user

  SystemNotificationDataContract notification = new SystemNotificationDataContract();

        notification.Users().value(1, curUserId());

        notification.Title("Export to Excel finished");

        notification.RuleId('ExcelStaticExport');

        notification.Message("We finished your export from the Customers page");

        notification.ExpirationDateTime(DateTimeUtil::addHours(DateTimeUtil::utcNow(), 48));

        notification.ReminderInterval(5);

    

        SystemNotificationsManager::AddNotification(notification);

Tuesday, 18 May 2021

AX 2012 X++ Consume aif web service by passing list of objects

 1- Create data contract class as below

[DataContractAttribute]

class HP_TestContract

{

    str Id;

    str Name;


[DataMemberAttribute('Id'), SysOperationDisplayOrderAttribute('1')]

public str ParamId(str _Id = Id)

{

    Id = _Id;

    return Id;

}

[DataMemberAttribute('Name'), SysOperationDisplayOrderAttribute('2')]

public str ParamName(str _Name = Name)

{

    Name = _Name;

    return Name;

}

}

2-Add an AIF service method

[SysEntryPointAttribute(true),
DataMemberAttribute("HP_TestContract"),
AifCollectionTypeAttribute("_contactList",Types::Class, classStr(HP_TestContract)),
AifCollectionTypeAttribute("return",Types::Class, classStr(HP_TestContract))]
public List HeshamList(List _contactList)
{
//_contactList = contactList;
return _contactList;
}

Tuesday, 6 April 2021

AX365 Dev machine import and Export restore a DB .bacpac file from the UAT

 Download the  Get sqlpackage .NET Core for Windows


Extract the folder and run the command prompt as an administrator, and run the below command


SqlPackage.exe /a:import /sf:D:\Hesham\SafariUATbackup.bacpac /tsn:localhost /tdn:AxDB /p:CommandTimeout=1200  /ttsc:True


Export 


SqlPackage.exe /a:export /TargetFile:H:\BiKeyDB.bacpac /SourceConnectionString:"Server=localhost;Initial Catalog=AxDB;Persist Security Info=False;User ID=sa;Password=sa;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=True;Connection Timeout=1200";