SBX - Search With Button

SBX - Forum Post Title

How to compare system generated Created Date and Time field of two table?

Microsoft Dynamics AX Forum

Uk257 asked a question on 13 Jul 2018 2:47 AM

Question Status

Verified

I have created two Table each with two records.

And i created One form then i put those two tables in datasource.

Now in my form grid i have all fields from Table1 and Table2 including Created Date and  Time.

Here my requirement is,

i need to compare those two Created Date and  Time fields on grid

if Table1 field is later than Table2 field then i need to disable that record in grid

How to compare system generated fields in condition?

And where should write the code?

Reply
Verified Answer

Hi Uk257,

You need to put this code in active() method of form datasource, so it gets executed whenever you select a record. There is nothing special with system generated fields and you can compare them as any other field.

Reply
Uk257 responded on 13 Jul 2018 4:36 AM

Hi ievgen Miroshnikov ,

Thanks for your response.

I have two data source in form, which one i have to choose to write code in active method.

and also how to get current record created date time field in active method

i wrote code like this in my Table1 data source

but disable whole grid as non editable.

if (table1.Createddatetime > table2.createddatetime)

{

    table1_ds.allowedit(false);

}

Reply
Anton Venter responded on 13 Jul 2018 4:45 AM
My Badges

The active method is called every time you select another row in the grid, you also have to enable editing again if table1.createdDateTime < table2.createdDateTime.

if (table1.Createddatetime > table2.createddatetime)
{
    table1_ds.allowedit(false);
}
else
{
    table1_ds.allowedit(true);
}


Reply

Just to add to previous response, you need to put this code on active of main data source. So if table2 is joined to table1 then put it on active of table1.

Reply
Uk257 responded on 13 Jul 2018 6:07 AM

Hi ievgen Miroshnikov ,

There is no relation between two tables.

Reply

So do you have 2 grids then or if they are in the same grid they should be joined by some fields...

Reply
Verified Answer

Hi Uk257,

You need to put this code in active() method of form datasource, so it gets executed whenever you select a record. There is nothing special with system generated fields and you can compare them as any other field.

Reply

SBX - Two Col Forum

SBX - Migrated JS