Hi to all,

 

����������� to bring a little bit clarification to this discussion, let me explain the purpose of the systemfields and the possibilities to change values of them:

 

(1)     manipulation of systemfields of each table will be handled by the kernel

(2)     systemfields are all fields, which will be shown on the tables property sheet:



plus:
����� TableId
����� RecId
����� DataAreaId

(3)     systemfields from the table property sheet can be overwritten; the three other ones can not.

(4)     overwriting of an systemfield can NOT be performed in the “normal” X++ way which would be:

public static void thisWillcauseAnComilerError(Args _args)
{
����� Table1������������������������� table1;
����� ;
����� ttsbegin;
����� table1 = Table1::find(“1”, true);
����� table1.ModifiedBy = “XMen”;�� // this code line causes an compiler error� 31: “The field must be a data element that allows assignment.”
����� table1.update();
����� ttscommit;
}

(5)     instead of the code above it is essential to address the field by using the fieldnum() function like:

public static void thisWillNotcauseAnComilerError(Args _args)
{
����� Table1������������������������� table1;
����� ;
����� ttsbegin;
����� table1 = Table1::find(“1”, true);
����� table1.(fieldnum(Table1, ModifiedBy)) = “XMen”; ����������� // this will not cause an comiler error – but…
����� table1.update();������������ ���������� ���������������������������������� // this will not update the selected record(s)
����� ttscommit;
}

(6)     as already mentioned in this discussion, solution (5) will not work. this is due to the fact that the kernel will NOT generate and send the sql-update statement to the database, ‘cause the only field which was changed is the (system!!! - ) field “ModifiedBy”. to force the kernel generating/sending the sql-update statement it is necessary to CHANGE the value of an other (non system!!! - ) field of the selected record. so the solution for the example above would be:

public static void thisWillWorkAsExpected(Args _args)
{
����� Table1������������������������� table1;
����� ;
����� ttsbegin;
����� table1 = Table1::find(“1”, true);
����� table1.(fieldnum(Table1, ModifiedBy)) ���� �= “XMen”;
����� table1.Counter������������������������������������� += 1;
����� table1.update();������������ ���������� �����������������������
����� ttscommit;
}

 

 

����������� best regards an nice weekend to all

����������� wolfgang

 

 

Hi

I remember to have read somewhere (probably in Technet) that you can only
overwrite the systemfields when inserting records. So, only "createdBy" and
the like can be set manually, but not "modifiedBy" etc.

The only solution for you I can think of is di
rectly writing SQL statements
(either in SQL tool or with Axapta connection/statement).

Best regards
Helmut Wimmer

-----Urspr�ngliche Nachricht-----
Von: Henrik �sterg�rd [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 22. J�nner 2004 15:17
An: [EMAIL PROTECTED]
Betreff: RE: [development-axapta] Re: overwritesystemfields doesnt work



>-- Oprindelig Besked --
>To: [EMAIL PROTECTED]
>From: "agramm2000" <[EMAIL PROTECTED]>
>Date: Thu, 22 Jan 2004 13:55:52 -0000
>Subject: [development-axapta] Re: overwritesystemfields doesnt work
>Reply-To: [EMAIL PROTECTED]
>
>
>--- In [EMAIL PROTECTED], Henrik �sterg�rd
><[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Could anyone please tell me why the systemfield "ModifiedBy" doesnt
>seem
>> to be updated.
>> Its for an conversion from XAL, where some transacts uses these
>fields.
>> Dirty trick would be to make a new field, but I would rather not.
>>
>>
>>    ttsbegin
>>    cg = custgroup::find("test1",true);
>>
>> info(cg.modifiedby);
>>    cg.overwriteSystemfields(true);
>>    cg.(fieldname2id(cg.TableId,"modifiedBy")) = "test";
>>    cg.update();
>>
>>    ttscommit;
>> info(cg.modifiedby);
>>
>> Rgz, Henrik
>
>Did you enable "Modified By" in property of table custgroup? It it not
>enabled in standard.
>
>Regards
>Andi

Hi Andi
I did now, but it didnt help.
rqz, Henrik





Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/

To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

Your use of Yahoo! Groups is subject to:  http://docs.yahoo.com/info/terms/


Yahoo! Groups Links

�         To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
 

�         To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
 

�         Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




Yahoo! Groups Links

<<image001.jpg>>

Reply via email to