Run code after Update of Record

HaribabuHaribabu Member Posts: 33
Hi,

I want to Run an XML port once a record is modified, i have added the code in the ONMODIFY() Trigger.
CodeLike this

OnModify()

ItemMaster.SetNo(ItemNo);
ItemMaster.RUN();

this triggers the xmlport but it generates the xml file with LAST saved records.

No. = item1
Desc = Test Item

i changed the description to ITEM1 and tab it , the xml file is generated but with no and description as the same as
given above..

how can i get the updated values in the XML file ??

Any help would be great.

Comments

  • David_CoxDavid_Cox Member Posts: 509
    OnModify has not yet commited the record, so it is in effect getting xrec, what you need to do is pass rec to the xmlport.

    Try,
    OnModify()

    CLEAR(ItemMaster);
    ItemMaster.SetTableView(Rec);
    ItemMaster.RUN();

    If that does not work, Create a temporary record variable of type Item, remember to make sure the property is set to temporary.

    CLEAR(TempItem);
    TempItem.INIT;
    TempItem.TRANSFERFIELDS(Rec);
    TempItem.INSERT;

    CLEAR(ItemMaster);
    ItemMaster.SetTableView(TempItem);
    ItemMaster.RUN();

    I did not think there is a XMLPort.RUN??
    These are the functions in 'Version 5' no RUN for XMLPort is this new in 5.1/2009??
    ItemXML.SETTABLEVIEW(Rec);
    ItemXML.SETTABLEVIEW(Record);
    ItemXML.SETSOURCE(Instream);
    ItemXML.SETRESPONSE(OutStream);
    ItemXML.GETRESPONSE(OutStream);
    ItemXML.IMPORT(TRUE);
    ItemXML.SETDESTINATION(OutStream);
    ItemXML.EXPORT(TRUE);

    David :?
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • HaribabuHaribabu Member Posts: 33
    Hi David,
    Sorry the as you said XMLPort Run Does not exist ,
    This is the code that i have written in the OnModify() method in the Item Masters Table

    OnModify()

    ItemNo := TempItem."No.";
    CLEAR(TempItem);
    TempItem.INIT;
    TempItem.TRANSFERFIELDS(Rec);
    TempItem.INSERT;

    IF EXISTS ('C:\Item.XML') THEN
    ERASE ('C:\Item.XML');

    TestFile.CREATE('C:\Item.XML');
    TestFile.CREATEOUTSTREAM(TestStream);
    Item.SetNo(ItemNo);
    CLEAR(Item);
    Item.SETTABLEVIEW(TempItem);
    Item.SetNo(ItemNo);
    Item.SETDESTINATION(TestStream);
    Item.EXPORT;
    TestFile.CLOSE;
    MESSAGE('Export complete');

    When i change some values and then close the form it throws a message saying

    "The Item XMLport dose not have a XMLItem that uses the table(Table 27 Item)specified in the function SetTableView".
    I am unable to find out why it is happening..


    Any help would be great.
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.