Discussion:
Create Sales Order Lines from outside SalesOrder Form..??
(too old to reply)
Hamza
2008-06-15 07:15:00 UTC
Permalink
Dear All,
I know i can make only lines from the sales order form......but i have a
customized form operate as lines creation in the sales order form this is my
situation:
1. I have a customized form called by MenuItemButton related to the
datasource propoerty (SalesTable).
2. In the customized form the code which writen inside operate the sales
lines creation.
3. When i run my form and select the lines which will be inserted to the
selected sales order header an error applied for filling the
Currency,Group,Customer,Requested ship date.
Although they were filled in the header creation.
So, How i can connect my customized form with the salesorder headers.
Note: The relation between my datasource and the salesTable datasource is
delayed type.
Thanks All.
Mathias
2008-06-15 11:21:00 UTC
Permalink
Hello,

i think you have a problem with creation of saleslines not salestable. Check
the sales line create code.

I got an example how to create a sales order . (It is in german)
http://starside.eu/PermaLink,guid,6c149fe7-050f-4f28-be3b-ac4b30247c47.aspx

Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear All,
I know i can make only lines from the sales order form......but i have a
customized form operate as lines creation in the sales order form this is my
1. I have a customized form called by MenuItemButton related to the
datasource propoerty (SalesTable).
2. In the customized form the code which writen inside operate the sales
lines creation.
3. When i run my form and select the lines which will be inserted to the
selected sales order header an error applied for filling the
Currency,Group,Customer,Requested ship date.
Although they were filled in the header creation.
So, How i can connect my customized form with the salesorder headers.
Note: The relation between my datasource and the salesTable datasource is
delayed type.
Thanks All.
Hamza
2008-06-15 12:29:01 UTC
Permalink
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
lines in predetermined salesorder header:
ttsbegin;
SalesLine.clear();

SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;

while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}

Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}

SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;

Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}

select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}

SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;

Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;

SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;


if (SalesLine.validateWrite())
SalesLine.Insert();

ttscommit;

LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Mathias
2008-06-15 13:37:07 UTC
Permalink
Hello,

its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?

Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Hamza
2008-06-15 14:00:01 UTC
Permalink
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Axel Kühn
2008-06-15 14:43:00 UTC
Permalink
Hi,

to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.

Example:
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);

inventTable = InventTable::find(AutoMotiveTable.ItemId);

salesLine.initValue();
salesLine.initFromSalesTable(salesTable);

saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);

SalesLIne.SalesQty = AutoMotiveTable.Quantity;

salesLine.initSalesQty();

SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;

salesLine.createLine(true, false, false, true, true, true, true, false);

Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Hamza
2008-06-16 07:59:00 UTC
Permalink
Dear Mr.Axel Kühn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.
Post by Axel Kühn
Hi,
to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);
inventTable = InventTable::find(AutoMotiveTable.ItemId);
salesLine.initValue();
salesLine.initFromSalesTable(salesTable);
saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);
SalesLIne.SalesQty = AutoMotiveTable.Quantity;
salesLine.initSalesQty();
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
salesLine.createLine(true, false, false, true, true, true, true, false);
Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Axel Kühn
2008-06-16 09:50:01 UTC
Permalink
Hi,

you have a handle/buffer to your marked salestable, right?

If so, you only need to assign the field salesid of the marked salesTable to
the salesline record (field salesId). This is done by calling
"salesLine.initFromSalesTable(<markedRecordOfSalesTable>)". This call also
sets other fields like CustAccount, CustGroup and Currency.

Just pass the marked salesTable record as the parameter to the method
"initFromSalestable" of the table "SalesLine".
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel Kühn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.
Post by Axel Kühn
Hi,
to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);
inventTable = InventTable::find(AutoMotiveTable.ItemId);
salesLine.initValue();
salesLine.initFromSalesTable(salesTable);
saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);
SalesLIne.SalesQty = AutoMotiveTable.Quantity;
salesLine.initSalesQty();
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
salesLine.createLine(true, false, false, true, true, true, true, false);
Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Hamza
2008-06-16 10:13:02 UTC
Permalink
Dear Mr.Axel ,
Thanks alot again it works just by your help thanks again, But there is one
thing dose not happen, after what i did form your help....although the lines
created in the marked header but they (lines) did not viewed directly....So
to see them i must to leave from the marked header then return back to the
header to see the inserted lines (How i can see them directly, which means
after the insertion process)
Note: i tried:
SalesTable_ds.executeQuery();
SalesTable_ds.Reread();
SalesTable_ds.Refresh();
But they did not make any change
Please help me in this problem.
And Sure Thanks again.
Post by Axel Kühn
Hi,
you have a handle/buffer to your marked salestable, right?
If so, you only need to assign the field salesid of the marked salesTable to
the salesline record (field salesId). This is done by calling
"salesLine.initFromSalesTable(<markedRecordOfSalesTable>)". This call also
sets other fields like CustAccount, CustGroup and Currency.
Just pass the marked salesTable record as the parameter to the method
"initFromSalestable" of the table "SalesLine".
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel Kühn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.
Post by Axel Kühn
Hi,
to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);
inventTable = InventTable::find(AutoMotiveTable.ItemId);
salesLine.initValue();
salesLine.initFromSalesTable(salesTable);
saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);
SalesLIne.SalesQty = AutoMotiveTable.Quantity;
salesLine.initSalesQty();
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
salesLine.createLine(true, false, false, true, true, true, true, false);
Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Axel Kühn
2008-06-16 11:01:02 UTC
Permalink
Hi Hamza,

please try to call SalesLine_ds.research() after the super() call in the
clicked method of your menuitem on the SalesTable form.

Example:

void clicked()
{
super();
SalesLine_DS.research();
}
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel ,
Thanks alot again it works just by your help thanks again, But there is one
thing dose not happen, after what i did form your help....although the lines
created in the marked header but they (lines) did not viewed directly....So
to see them i must to leave from the marked header then return back to the
header to see the inserted lines (How i can see them directly, which means
after the insertion process)
SalesTable_ds.executeQuery();
SalesTable_ds.Reread();
SalesTable_ds.Refresh();
But they did not make any change
Please help me in this problem.
And Sure Thanks again.
Post by Axel Kühn
Hi,
you have a handle/buffer to your marked salestable, right?
If so, you only need to assign the field salesid of the marked salesTable to
the salesline record (field salesId). This is done by calling
"salesLine.initFromSalesTable(<markedRecordOfSalesTable>)". This call also
sets other fields like CustAccount, CustGroup and Currency.
Just pass the marked salesTable record as the parameter to the method
"initFromSalestable" of the table "SalesLine".
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel Kühn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.
Post by Axel Kühn
Hi,
to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);
inventTable = InventTable::find(AutoMotiveTable.ItemId);
salesLine.initValue();
salesLine.initFromSalesTable(salesTable);
saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);
SalesLIne.SalesQty = AutoMotiveTable.Quantity;
salesLine.initSalesQty();
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
salesLine.createLine(true, false, false, true, true, true, true, false);
Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Hamza
2008-06-17 10:34:02 UTC
Permalink
Dear Mr.Axel,
Thanks again for your help but what you told me about the saleslines
creation and see them directly to write in the menuitembutton
void clicked()
{
Super();
SalesLine_ds.research();
}
does not make anything, so if you know another solution please tell me
(How I see the Lines after their creation directly?)
Please Help me.
Thanks again.
Post by Axel Kühn
Hi Hamza,
please try to call SalesLine_ds.research() after the super() call in the
clicked method of your menuitem on the SalesTable form.
void clicked()
{
super();
SalesLine_DS.research();
}
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel ,
Thanks alot again it works just by your help thanks again, But there is one
thing dose not happen, after what i did form your help....although the lines
created in the marked header but they (lines) did not viewed directly....So
to see them i must to leave from the marked header then return back to the
header to see the inserted lines (How i can see them directly, which means
after the insertion process)
SalesTable_ds.executeQuery();
SalesTable_ds.Reread();
SalesTable_ds.Refresh();
But they did not make any change
Please help me in this problem.
And Sure Thanks again.
Post by Axel Kühn
Hi,
you have a handle/buffer to your marked salestable, right?
If so, you only need to assign the field salesid of the marked salesTable to
the salesline record (field salesId). This is done by calling
"salesLine.initFromSalesTable(<markedRecordOfSalesTable>)". This call also
sets other fields like CustAccount, CustGroup and Currency.
Just pass the marked salesTable record as the parameter to the method
"initFromSalestable" of the table "SalesLine".
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel Kühn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.
Post by Axel Kühn
Hi,
to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);
inventTable = InventTable::find(AutoMotiveTable.ItemId);
salesLine.initValue();
salesLine.initFromSalesTable(salesTable);
saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);
SalesLIne.SalesQty = AutoMotiveTable.Quantity;
salesLine.initSalesQty();
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
salesLine.createLine(true, false, false, true, true, true, true, false);
Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
Axel Kühn
2008-06-18 08:21:01 UTC
Permalink
Hi Hamza,

sorry, if forgot that you are working with a form.
What i have posted befor only work when you are not using visuell elements
like forms to create new saleslines.

But this should work for you....

you can try this:

..in the classdeclaration of you from instanciate a new FormObjectSet Object
to store the reference to your salesTable datasource on the salestable form.

example:
public class FormRun extends ObjectRun
{
FormObjectSet callerDS;
}

After that you can override the init method of you form to set the
FormObjectSet object.

Example:
public void init()
{
super();

if(element.args().record().isFormDataSource())
{
callerDs = element.args().record().dataSource();
}
}

Finally you must override the close method fo your form to refresh the
Datasource of the salesTable form when you close your new form.

Example:
public void close()
{
;
super();
callerDs.research();
}


Hope that helps you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel,
Thanks again for your help but what you told me about the saleslines
creation and see them directly to write in the menuitembutton
void clicked()
{
Super();
SalesLine_ds.research();
}
does not make anything, so if you know another solution please tell me
(How I see the Lines after their creation directly?)
Please Help me.
Thanks again.
Post by Axel Kühn
Hi Hamza,
please try to call SalesLine_ds.research() after the super() call in the
clicked method of your menuitem on the SalesTable form.
void clicked()
{
super();
SalesLine_DS.research();
}
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel ,
Thanks alot again it works just by your help thanks again, But there is one
thing dose not happen, after what i did form your help....although the lines
created in the marked header but they (lines) did not viewed directly....So
to see them i must to leave from the marked header then return back to the
header to see the inserted lines (How i can see them directly, which means
after the insertion process)
SalesTable_ds.executeQuery();
SalesTable_ds.Reread();
SalesTable_ds.Refresh();
But they did not make any change
Please help me in this problem.
And Sure Thanks again.
Post by Axel Kühn
Hi,
you have a handle/buffer to your marked salestable, right?
If so, you only need to assign the field salesid of the marked salesTable to
the salesline record (field salesId). This is done by calling
"salesLine.initFromSalesTable(<markedRecordOfSalesTable>)". This call also
sets other fields like CustAccount, CustGroup and Currency.
Just pass the marked salesTable record as the parameter to the method
"initFromSalestable" of the table "SalesLine".
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Axel Kühn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.
Post by Axel Kühn
Hi,
to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);
inventTable = InventTable::find(AutoMotiveTable.ItemId);
salesLine.initValue();
salesLine.initFromSalesTable(salesTable);
saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);
SalesLIne.SalesQty = AutoMotiveTable.Quantity;
salesLine.initSalesQty();
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
salesLine.createLine(true, false, false, true, true, true, true, false);
Hope this solves your problem....
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Hamza
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.
Post by Mathias
Hello,
its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?
Kind regards
--
Mathias Füßler
my blog: http://starside.eu
Post by Hamza
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
ttsbegin;
SalesLine.clear();
SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;
while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}
Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}
SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;
Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}
select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}
SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;
Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;
SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;
if (SalesLine.validateWrite())
SalesLine.Insert();
ttscommit;
LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias
unknown
2008-08-28 10:37:24 UTC
Permalink
can u please breif me on
" handle/buffer " in salestable form that u have suggested
Axel Kühn
2008-08-28 18:03:01 UTC
Permalink
Hi

handle / buffer means:

SalesTable curSalesTableRecord;
;
select firstonly curSalesTableRecord;

curSalesTableRecord is a buffer which holds an record of the table
"SalesTable"

And for the definition of a buffer please take a look at this link:
http://en.wikipedia.org/wiki/Buffer_(computer_science)
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by unknown
can u please breif me on
" handle/buffer " in salestable form that u have suggested
unknown
2010-06-09 09:01:13 UTC
Permalink
Im trying to populate the sales line from .net. But im getting the similar error for filling the Currency,Group,Customer,Requested ship date.

Although they were filled in the header creation.
I tried the following code

public boolean insertSalesLine(
ItemId _itemId, CostPrice _costPrice,
Qty _qty, ItemFreeTxt _text = "")
{
InventTable item;
;
salesLine.clear();
salesLine.initValue();
salesLine.SalesId = salesTable.SalesId;
item = InventTable::find(_itemId);
salesLine.ItemId = item.ItemId;
salesLine.Name = item.ItemName;
salesLine.initFromInventTable(item);
salesLine.initFromSalesTable(salesTable);
salesLine.SalesPrice = _costPrice;
salesLine.SalesQty = _qty;
salesLine.initSalesQty();
salesLine.LineAmount = salesLine.calcLineAmount();
salesLine.LineNum = salesLine::lastLineNum( salesLine.SalesId) + 1;
salesLine.createLine(true,false,false,true,true,false);
return true;
}

kindly help




AxelKh wrote:

Hi,to be sure that you have specified all necessary fields please work the the
15-Jun-08

Hi,

to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.

Example:
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);

inventTable = InventTable::find(AutoMotiveTable.ItemId);

salesLine.initValue();
salesLine.initFromSalesTable(salesTable);

saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);

SalesLIne.SalesQty = AutoMotiveTable.Quantity;

salesLine.initSalesQty();

SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;

salesLine.createLine(true, false, false, true, true, true, true, false);

Hope this solves your problem....
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)


"Hamza" wrote:

Previous Posts In This Thread:

On Sunday, June 15, 2008 3:15 AM
Hamz wrote:

Create Sales Order Lines from outside SalesOrder Form..??
Dear All,
I know i can make only lines from the sales order form......but i have a
customized form operate as lines creation in the sales order form this is my
situation:
1. I have a customized form called by MenuItemButton related to the
datasource propoerty (SalesTable).
2. In the customized form the code which writen inside operate the sales
lines creation.
3. When i run my form and select the lines which will be inserted to the
selected sales order header an error applied for filling the
Currency,Group,Customer,Requested ship date.
Although they were filled in the header creation.
So, How i can connect my customized form with the salesorder headers.
Note: The relation between my datasource and the salesTable datasource is
delayed type.
Thanks All.

On Sunday, June 15, 2008 7:21 AM
MathiasFuessle wrote:

Hello,i think you have a problem with creation of saleslines not salestable.
Hello,

i think you have a problem with creation of saleslines not salestable. Check
the sales line create code.

I got an example how to create a sales order . (It is in german)
http://starside.eu/PermaLink,guid,6c149fe7-050f-4f28-be3b-ac4b30247c47.aspx

Kind regards
--
Mathias F????ler
my blog: http://starside.eu



"Hamza" wrote:

On Sunday, June 15, 2008 8:29 AM
Hamz wrote:

Dear Mr.
Dear Mr.Mathias,
This is my salesline creation code, Please check if there is missing to add
lines in predetermined salesorder header:
ttsbegin;
SalesLine.clear();

SalesLine.SalesId = SalesOrderId;
SalesLine.LineNum = LineNum;
SalesLine.ItemId = AutoMotiveTable.ItemId;
SalesLine.SalesStatus = 1;
SalesLine.Name = AutoMotiveTable.ItemName;
SalesLine.QtyOrdered = AutoMotiveTable.Quantity;
SalesLine.RemainSalesPhysical = AutoMotiveTable.Quantity;

while select inventDim
where (inventdim.inventBatchId == '' && inventDim.wMSLocationId
== '' && inventDim.wMSPalletId == '' && inventDim.inventSerialId == ''
&& inventdim.InventLocationId == AutoMotiveTable.Warehouse &&
inventdim.InventColorId == '' && inventdim.InventSizeId ==
AutoMotiveTable.Location && inventdim.configId == '')
{
Salesline.InventDimId = inventDim.inventDimId;
}

Select inventTableModule
where (inventTableModule.ItemId == AutoMotiveTable.ItemId);
{
Salesline.CostPrice = inventTableModule.Price;
}

SalesLine.SalesPrice = AutoMotiveTable.UnitPrice;
SalesLine.CurrencyCode = Currency;
SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;

Select inventTable
Where (InventTable.ItemId == AutoMotiveTable.ItemId);
{
SalesLine.Dimension = inventTable.Dimension;
SalesLine.Dimension[2] = inventTable.Dimension[2];
SalesLine.Dimension[3] = inventTable.Dimension[3];
}

select NumberSequenceTable
where (NumberSequenceTable.NumberSequence == 'Inve_59');
{
numberSeq =
NumberSeq::newGetNumFromCode(NumberSequenceTable.NumberSequence);
SalesLine.InventTransId = numberseq.num();
}

SalesLine.CustGroup = CustGroup;
SalesLine.CustAccount = CustAccount;
SalesLine.SalesQty = AutoMotiveTable.Quantity;
SalesLine.SalesType = SalesTable.SalesType;

Salesline.RemainInventPhysical = AutoMotiveTable.Quantity;

SalesLine.SalesGroup = SalesTable.SalesGroup;
SalesLine.ReceiptDateRequested = SalesTable.ReceiptDateRequested;
SalesLine.ShippingDateRequested =
SalesTable.ShippingDateRequested;


if (SalesLine.validateWrite())
SalesLine.Insert();

ttscommit;

LineNum = LineNum + 1;
ttscommit;
This code inside a while loop.
Please Help Me.
Thanks Mr.Mathias

On Sunday, June 15, 2008 9:37 AM
MathiasFuessle wrote:

Hello,its probably the best to debug your code.
Hello,

its probably the best to debug your code. take a look at the variables
custgroup, custaccount ect. because you are getting the error of these?

Kind regards
--
Mathias F????ler
my blog: http://starside.eu



"Hamza" wrote:

On Sunday, June 15, 2008 10:00 AM
Hamz wrote:

Dear Mr.Mathias,My situation is to add lines to a header was already created.
Dear Mr.Mathias,
My situation is to add lines to a header was already created.
I know i disturbe you but really i want to solve this problem.....i think i
don't have to check about the custaccount, custgroup because they already
created in the header....please tell me if i have to....
Thanks again.

"Mathias" wrote:

On Sunday, June 15, 2008 10:43 AM
AxelKh wrote:

Hi,to be sure that you have specified all necessary fields please work the the
Hi,

to be sure that you have specified all necessary fields please work the the
salesline.initfromXXX methods.

Example:
SalesId salesId = "00428_036"; //id of the sales header
SalesTable salesTable;
InventTable inventTable;
SalesLine salesLine;
;
SalesLine.clear();
salesTable = SalesTable::find(salesId);

inventTable = InventTable::find(AutoMotiveTable.ItemId);

salesLine.initValue();
salesLine.initFromSalesTable(salesTable);

saleslIne.ItemId = inventTable.ItemId;
salesLine.initFromInventTable(inventTable);

SalesLIne.SalesQty = AutoMotiveTable.Quantity;

salesLine.initSalesQty();

SalesLine.LineAmount = AutoMotiveTable.UnitPrice *
AutoMotiveTable.Quantity;
SalesLine.SalesUnit = AutoMotiveTable.Unit;

salesLine.createLine(true, false, false, true, true, true, true, false);

Hope this solves your problem....
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)


"Hamza" wrote:

On Monday, June 16, 2008 3:59 AM
Hamz wrote:

Dear Mr.
Dear Mr.Axel K??hn,
Thanks alot for helping me, it works for the salesid when i assiened it a
static value the question how i can make the code take the salesid for the
marked record.?
After i put your example code it works also for a static values for
(CustAccount,CustGroup,Currency) how i got these values also for the marked
sales header record.
Please help me.
Thanks again.

"Axel K??hn" wrote:

On Monday, June 16, 2008 5:50 AM
AxelKh wrote:

Hi,you have a handle/buffer to your marked salestable, right?
Hi,

you have a handle/buffer to your marked salestable, right?

If so, you only need to assign the field salesid of the marked salesTable to
the salesline record (field salesId). This is done by calling
"salesLine.initFromSalesTable(<markedRecordOfSalesTable>)". This call also
sets other fields like CustAccount, CustGroup and Currency.

Just pass the marked salesTable record as the parameter to the method
"initFromSalestable" of the table "SalesLine".
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)


"Hamza" wrote:

On Monday, June 16, 2008 6:13 AM
Hamz wrote:

Dear Mr.
Dear Mr.Axel ,
Thanks alot again it works just by your help thanks again, But there is one
thing dose not happen, after what i did form your help....although the lines
created in the marked header but they (lines) did not viewed directly....So
to see them i must to leave from the marked header then return back to the
header to see the inserted lines (How i can see them directly, which means
after the insertion process)
Note: i tried:
SalesTable_ds.executeQuery();
SalesTable_ds.Reread();
SalesTable_ds.Refresh();
But they did not make any change
Please help me in this problem.
And Sure Thanks again.

"Axel K??hn" wrote:

On Monday, June 16, 2008 7:01 AM
AxelKh wrote:

Hi Hamza,please try to call SalesLine_ds.
Hi Hamza,

please try to call SalesLine_ds.research() after the super() call in the
clicked method of your menuitem on the SalesTable form.

Example:

void clicked()
{
super();
SalesLine_DS.research();
}
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)


"Hamza" wrote:

On Tuesday, June 17, 2008 6:34 AM
Hamz wrote:

Dear Mr.
Dear Mr.Axel,
Thanks again for your help but what you told me about the saleslines
creation and see them directly to write in the menuitembutton
void clicked()
{
Super();
SalesLine_ds.research();
}
does not make anything, so if you know another solution please tell me
(How I see the Lines after their creation directly?)
Please Help me.
Thanks again.

"Axel K??hn" wrote:

On Wednesday, June 18, 2008 4:21 AM
AxelKh wrote:

Hi Hamza,sorry, if forgot that you are working with a form.
Hi Hamza,

sorry, if forgot that you are working with a form.
What i have posted befor only work when you are not using visuell elements
like forms to create new saleslines.

But this should work for you....

you can try this:

..in the classdeclaration of you from instanciate a new FormObjectSet Object
to store the reference to your salesTable datasource on the salestable form.

example:
public class FormRun extends ObjectRun
{
FormObjectSet callerDS;
}

After that you can override the init method of you form to set the
FormObjectSet object.

Example:
public void init()
{
super();

if(element.args().record().isFormDataSource())
{
callerDs = element.args().record().dataSource();
}
}

Finally you must override the close method fo your form to refresh the
Datasource of the salesTable form when you close your new form.

Example:
public void close()
{
;
super();
callerDs.research();
}


Hope that helps you.
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)


"Hamza" wrote:

On Thursday, August 28, 2008 6:37 AM
keyur shah wrote:

Create Sales Order Lines from outside SalesOrder Form..??
can u please breif me on
" handle/buffer " in salestable form that u have suggested

On Thursday, August 28, 2008 2:03 PM
AxelKh wrote:

RE: Create Sales Order Lines from outside SalesOrder Form..??
Hi

handle / buffer means:

SalesTable curSalesTableRecord;
;
select firstonly curSalesTableRecord;

curSalesTableRecord is a buffer which holds an record of the table
"SalesTable"

And for the definition of a buffer please take a look at this link:
http://en.wikipedia.org/wiki/Buffer_(computer_science)
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)


"keyur shah" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Parallel Programming in C# 4.0: A Short Synopsis
http://www.eggheadcafe.com/tutorials/aspnet/047afdf6-61ab-4b85-9204-b0f20bdc955a/parallel-programming-in-c.aspx
Loading...