Question Status

Verified
Gautam . asked a question on 3 Mar 2015 12:12 AM

hey guys i am just doing  a small project in dynamics AX 2012 as i am beginner  and new to AX.

In sells form i want to take multiple record at a time and then want to save these data into my sellsTable(table name) and each record consists of these fields that is sellsid, itemid, itemname, itemquantity, itemunitprice, totalcost, date.

so suggest me how should i procceed.   


 

Reply
Suggested Answer
Sohaib Cheema responded on 3 Mar 2015 12:14 AM

i guess its same question and answer as here

Reply
Gautam . responded on 3 Mar 2015 12:17 AM

no sohaib

Reply
Sohaib Cheema responded on 3 Mar 2015 12:23 AM

then, I am unable to understand your issue/ scenario

Reply
Gautam . responded on 3 Mar 2015 12:35 AM

sohaib it may be the answer i dont know excatly .

as i am very new to dynamics AX  so i am unable to handle complex things .

my issue is that

i want to take value (multiple record) from grid and want to store into my sell table

and the scenario is that ..

i have made one sellsform(Form Name) for handling the billing regarding selling of products .

so i know how to take a single record from the form by using StringEdit but i dont know how to take multiple record from form .

i can use this StringEdit also here ..but what will happen when a customer buy more than one item at a time .so to overcome this problem i want to take multiple records at a time

my project is of supermarket 

Reply
Sohaib Cheema responded on 3 Mar 2015 12:38 AM

Gentleman you have to use grid and set multiselect  property of grid as true.

Reply
Gautam . responded on 3 Mar 2015 12:43 AM

ok sohaib i have done this  ..and one more thing how to get the values from the same grid

as i have created this grid without any datasource 

Reply
Suggested Answer
Sohaib Cheema responded on 3 Mar 2015 12:50 AM

As I referred to a previous post  

{

YoueTable yourTableObject;

;

yourTableObject = YoueTable _ds.getFirst(true);

while (yourTableObject)

{

              //any processing here any logic here;

//for your case you have to insert records in other tables here

yourTableObject = YoueTable _ds.getNext();

}

}

Reply
Sohaib Cheema responded on 3 Mar 2015 12:54 AM

I cannot understand why you are not using Datasource for your form, is there any special need, for not using DS??

Reply
Gautam . responded on 3 Mar 2015 12:57 AM

hey sohaib where should i write these codes

i mean i need to override any method of grid ??

if not then where should i ?

Reply
Gautam . responded on 3 Mar 2015 1:03 AM

ok sohaib . let me answer it

i am not using the datasource in grid because when i add the datasource then it will display the values from the table which i don't want .

suggest me what to do here ,if it is necessary to add DS then i will definetly add the DS  

Reply
Sohaib Cheema responded on 3 Mar 2015 1:13 AM

so you want, as the records go into your destination table, the records should be deleted from source form..???

Reply
Suggested Answer
Shiva Kumar responded on 3 Mar 2015 1:14 AM

From which table you are getting data to Sells form??

As per your question you have a sells form from there you want to store the selected records into sells table..I'm i right?

If yes then create a button in the sells form then override the clicked method with the sohaib logic..

hope its clear.

Reply
Gautam . responded on 3 Mar 2015 1:25 AM

yeah ..exactly sohaib

Reply
Gautam . responded on 3 Mar 2015 1:31 AM

ya you are right shiva

Reply
Sohaib Cheema responded on 3 Mar 2015 1:33 AM

Make a copy of your destination table. Now take this copy of destination table and set its TableType property to TempDB. now use this newly created temporary table as your DS in Source Form.

Reply
Verified Answer
Dominic Lee responded on 3 Mar 2015 7:52 PM

Hi Gautam,

Check this post:

daxmusings.codecrib.com/.../multi-select-on-form-datasource-grid.html

The code Shiva provided requires the record to be "marked" (check the post to see what does marked mean in this context) to work.

This same post provided two possible solutions

kind regards,

Dominic Lee

My blog | PBC

This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Reply
Suggested Answer
Sohaib Cheema responded on 3 Mar 2015 12:14 AM

i guess its same question and answer as here

Reply
Suggested Answer
Sohaib Cheema responded on 3 Mar 2015 12:50 AM

As I referred to a previous post  

{

YoueTable yourTableObject;

;

yourTableObject = YoueTable _ds.getFirst(true);

while (yourTableObject)

{

              //any processing here any logic here;

//for your case you have to insert records in other tables here

yourTableObject = YoueTable _ds.getNext();

}

}

Reply
Suggested Answer
Shiva Kumar responded on 3 Mar 2015 1:14 AM

From which table you are getting data to Sells form??

As per your question you have a sells form from there you want to store the selected records into sells table..I'm i right?

If yes then create a button in the sells form then override the clicked method with the sohaib logic..

hope its clear.

Reply
Suggested Answer
Shiva Kumar responded on 3 Mar 2015 4:00 AM

ok paste the below code on the clicked method of your button..

it will delete the selected records from the TempDB table & inserts the same into SellTable..

void clicked()

{

   TempDB _Table1,Tab1;

   Table10 sellstable;

   _Table1 = TempDB_ds.getfirst(true);

   while(_Table1)

   {

       sellstable.Field1 = _Table1.Field1;

       sellstable.Field2 = _Table1.Field2;

       sellstable.insert();

       delete_from Tab1 where  Tab1.RecId == _Table1.RecId;

       _Table1 = TempDB_ds.getnext();

   }

   TempDB_ds.research(true);

}

Let me know if any..

Reply