freezing multiple records in grid

here i m using dynamics ax 2009 … in my form ( sample table) fields are given ( sample Id , name , status) .

if my record status is open order selected records would be unfreeze … once i post the record it will be freezed … can any one help me for to freeze multiple records once i posted …

Please see my answer in your thread with the same name on another forum.

Hi all …

i got answer for freezing by selecting multiple grid records in form … here i use button click method for freeze grid records … below coding i using for it … working correctly

public int active()

{

int ret;

;

ret = super();

if(SampleTable.Permissions == permissions::No)

{

SampleTable_DS.allowEdit(false);

Button.enabled(false);

}

else

{

SampleTable_DS.allowEdit(true);

Button.enabled(true);

}

return ret;

}

///////////////////////////////////////////////////////////////

//<!------

// This click method is used to freeze the multiselected Records in the Grid

// by using container Class

//

//-------------------------!>

void clicked()

{

SampleTable sampleTable1,sampleTable2;

container con,conId;

int i,j;

;

i = 1;

sampleTable1 = SampleTable_DS.getFirst();

sampleTable2 = SampleTable_DS.getFirst();

for(sampleTable1 = SampleTable_DS.getFirst(true) ? SampleTable_DS.getFirst(true) : SampleTable_DS.cursor();sampleTable1;sampleTable1 = SampleTable_DS.getNext())

{

con = conins(con,i,sampleTable1.Status);

if(conpeek(con,i) !=0)

{

throw error("@PER218");

}

conId = conins(conId,i,sampleTable1.RecId);

i++;

}

for(j = 1 ; j <= conLen(con);j++)

{

if(conpeek(con,j) != 0)

{

throw error("@PER218");

}

else

{

ttsbegin;

while select forupdate sampleTable1 where sampleTable1.RecId == sampleTable2.RecId

{

sampleTable.Status = statusIdea::Posted;

sampleTable.Permissions = permissions::No;

sampleTable.update();

}

ttscommit;

SampleTable_DS.reread();

SampleTable_DS.refresh();

SampleTable_DS.active();

}

}

SampleTable_Ds.research();

super();

}

/////////////////////////////////////////////////////////////////////

public void init()

{

;

super();

this.query().dataSourceTable(tablenum(SampleTable)).addSortField(fieldnum(SampleTable,RecId),SortOrder::Descending);

}

Kavin, please mark the question as answered.

Hi everyone please find the attachment … i keep complete coding in this attachment

5684.freeze the multiple records in grid.txt (2.13 KB)

click() one error in previous code i post it mistakenly … here i put correct coding please check this one …

freeze the grid multiple records

public class FormRun extends ObjectRun

{

}

///////////////////////////////////////////

public void init()

{

;

super();

this.query().dataSourceTable(tablenum(SampleTable)).addSortField(fieldnum(SampleTable,RecId),SortOrder::Descending);

}

/////////////////////////////////////////

public int active()

{

int ret;

;

ret = super();

if(SampleTable.Permissions == permissions::No)

{

SampleTable_DS.allowEdit(false);

Button.enabled(false);

}

else

{

SampleTable_DS.allowEdit(true);

Button.enabled(true);

}

return ret;

}

//////////////////////////////////////////

//<!------

// This click method is used to freeze the multiselected Records in the Grid

// by using container Class

//

//-------------------------!>

void clicked()

{

SampleTable sampleTable1,sampleTable2;

container con;

int i;

;

i = 1;

sampleTable1 = SampleTable_DS.getFirst();

sampleTable2 = SampleTable_DS.getFirst();

for(sampleTable1 = SampleTable_DS.getFirst(true) ? SampleTable_DS.getFirst(true) : SampleTable_DS.cursor();sampleTable1;sampleTable1 = SampleTable_DS.getNext())

{

con = conins(con,i,sampleTable1.Status);

if(conpeek(con,i) !=0)

{

throw error("@PER218");

}

i++;

}

for(sampletable2 = SampleTable_DS.getFirst(1) ? SampleTable_DS.getFirst(1) : SampleTable_DS.cursor(); sampleTable2; sampleTable2 = SampleTable_DS.getNext())

{

ttsbegin;

while select forupdate sampleTable1 where sampleTable1.RecId == sampleTable2.RecId

{

sampleTable1.Status = statusIdea::Posted;

sampleTable1.Permissions = permissions::No;

sampleTable1.update();

}

ttscommit;

SampleTable_DS.reread();

SampleTable_DS.refresh();

SampleTable_DS.active();

}

SampleTable_Ds.research(true);

super();

}