Problem making new sales order

HI all,

i have write this code in location feild of Sales Order, in this code iam trying to update my all the dimension (include the document dimension) by location.

the code is working , but the problem is that while making a new sales order its reflect the error.

IF “Location Code” <> ‘’ THEN BEGIN
Location.GET(“Location Code”);
Shortcut Dimension 2 Code" := Location.“Dimension Value”;
END;

IF DocDim.“Dimension Value Code” = ‘’ THEN
DocDim.GET(“Shortcut Dimension 2 Code”);

DocDim.SETRANGE(“Table ID”,DATABASE::“Sales Line”);
DocDim.SETRANGE(“Document Type”,“Document Type”);
DocDim.SETRANGE(“Document No.”,“No.”);

DocDim.SETRANGE(“Dimension Code”,‘BRN’);
IF DocDim.FINDFIRST THEN

DocDim.“Dimension Value Code” := “Shortcut Dimension 2 Code”;

MESSAGE(‘the value %1’,“Shortcut Dimension 2 Code”);
DocDim.MODIFY := TRUE;

Regards,

Shailesh

I am not sure what are you trying to do with below code

IF DocDim.“Dimension Value Code” = ‘’ THEN
DocDim.GET(“Shortcut Dimension 2 Code”);

Did you try with below code

IF DocDim.FINDFIRST THEN Begin //Added Begin

DocDim.“Dimension Value Code” := “Shortcut Dimension 2 Code”;

MESSAGE(‘the value %1’,“Shortcut Dimension 2 Code”);
DocDim.MODIFY := TRUE;

END; //New Line

If it Didnt work then let me know the exact error message…

Hi Moahan

when iam using this code than suppose i make new SO than after picking my location the Document dimension is not updating.

it updating the previous SO, where the document dimension is already there

DocDim.SETRANGE(“Table ID”,DATABASE::“Sales Line”);
DocDim.SETRANGE(“Document Type”,“Document Type”);
DocDim.SETRANGE(“Document No.”,“No.”);

DocDim.SETRANGE(“Dimension Code”,‘BRN’);
IF DocDim.FINDFIRST THEN BEGIN

DocDim.“Dimension Value Code” := “Shortcut Dimension 2 Code”;

MESSAGE(‘the value %1’,“Shortcut Dimension 2 Code”);
DocDim.MODIFY := TRUE;
END;

Regards,

shailesh

Where is your insert code if the dimension is not found?

did you see my full example code in previous post

It should be

IF DocDim.FINDFIRST THEN BEGIN

DocDim.“Dimension Value Code” := “Shortcut Dimension 2 Code”;

MESSAGE(‘the value %1’,“Shortcut Dimension 2 Code”);
DocDim.MODIFY := TRUE;
END ELSE BEGIN

// Here you need to write insert code…

DocDim.INSERT(TRUE);

END;

Error While Making new SO

The Document Dimnsion Already Exists.

Identification feilds and values
Table ID=‘0’,Document Type=‘Quote’,Document No.=",Line No.=‘0’,Dimension Code="

regadrs,

shailesh

Your code is wrong…

you have to correct it…

Please assign values to all primary key fields…

iam unable to get you, can you give example how to do it.

Regards,

Shailesh

I can give you full code but when do you learn?

Please try and let me know what didnt work…

Before Insert(TRUE), you have to assign values to all primary key fields of DocDim.