Monday, 25 November 2013

adding image through resource

Upload image:

Use resource files in Axapta
In Application Object Tree, you can find resources node
. 
Select resources node and right click; select Create from File, specify the file location for the new resource 

file. After that you can use this resource file in Axapta without specifying an absolute file path in your 

local/server system.

First, pick up the resource node from AOT;


SysResource::getResourceNode(); 

Then generate a temporary file for this resource file;

SysResource::saveToTempFile() 

Finally specify the temporary file path for controls. 

Here comes an example to show how to use a resource file as a background image of  a given form. 

{
ResourceNode            resourceNode;
FilePath  imagename;
;
resourceNode = SysResource::getResourceNode(resourcestr(ResourceName));
if (resourceNode)
{
resourceNode. AOTload();
imagename =  SysResource::saveToTempFile(resourceNode);
}
else
{
throw Error(“No file exists.”)
} 

element.design().imageName(imagename); 
}

Example:

You can try "Resources" node to achieve your requirement.
Just Add a new resources under "Resources" node in AOT, than use following X++ code to access that image..
SysResource::getResourceNodeData(SysResource::getResourceNode('theaxapta_File'));



Create slaesline without item id:


Create slaesline without item id:
I am sure that there is a work around for this because when i am commenting the itemId and the salescategory the error will be : Item or category must be specified.

but when i want to add a salesaline with only sales categroy it will give me that "item ID must be specified". However ItemId can be nullable because on the AX Client i can create a salesline without an item.


As discussed in a parallel thread, sales lines without item IDs are supported from GUI, but there is an explicit validation in AxdSalesOrder.checkSalesLine():
if (!_axSalesLine.salesLine().RecId && !axSalesLine.parmItemId)
{
    error("@SYS300755"); // Item ID must be specified.
}

Comment this 4 lines of codes however i am still unable to create this salesorder then do this :

Ensure yourself that your changes have been compiled to CIL - if they're in X++ only, services won't see them.
If it doesn't help, then use the debugger to see what exactly is happening. Open Application Explorer in Visual Studio, add a breakpoint somewhere (e.g. toInfo.add()), attach the debugger to the AOS process and execute the service call.