Options

XMLport question

ccbryan63ccbryan63 Member Posts: 115
edited 2010-12-10 in NAV Three Tier
I am still trying to find a way to import a flat file into RTC (see my other thread) but in the meantime I'm thinking about converting my data to xml in order to import it. But I'm running into a problem with the XMLport. I need to do a little data manipulation but I can't find a way that NAV likes to refer to the data. Here is the top of my dataport fields list:
Node Name                       Node Type     Source Type         Data Source
------------                    -----------   -----------         -----------
Root                            Element       Text                <Root>
   Payroll Journal Line         Element       Table               <Payroll Journal Line>(Payroll Jouirnal Line)
      JournalTemplateName       Element       Field               <Payroll Journal Line>:: Journal template Name
      LineNo                    Element       Field               <Payroll Journal Line>:: Line No.
      DocumentType              Element       Field               <Payroll Journal Line>::Document Type
......

I want, let's say, to evaluate DocumentType like this
IF DocumentType  = 'Payment' THEN "Document Type" := 1
   ELSE "Document Type" := 0;

I have tried putting this in the PayrollJournalLine - Import::OnBeforeInsetRecord() and in the DocumnetType - Import::OnAfterAssignField() tiggers, but it won't compile, telling me that DocumentType is an unknown variable.

If someone could point me towards the proper way to refer to this field, I'd be very grateful...

Answers

  • Options
    kinekine Member Posts: 12,562
    Instead source =Field set Text. It will assign the data into variable and you can do your code on it.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    ccbryan63ccbryan63 Member Posts: 115
    Thank you for that guidance Kamil. I changed the source type of that node to Text and that does allow me to refer to the node value, but I still can't refer to the table/field I'm trying to populate.

    The XMLPort is working at this point (putting records into the Payroll Journal Line table), but I still can't adjust values. If I try this I get a compile error "unknown variable 'Payroll Journal Line' "
    NormalSign -- Import::OnAfterAssignVariable()
    ----------------------------------------
    IF NormalSign = 'Negative' THEN "Payroll Journal Line"."Normal Sign" := 0 ELSE "Payroll Journal Line"."Normal Sign" := 1;
    
    This gets "unknown variable 'Normal Sign' "
    NormalSign -- Import::OnAfterAssignVariable()
    ----------------------------------------
    IF NormalSign = 'Negative' THEN "Normal Sign" := 0 ELSE "Normal Sign" := 1;
    
    Trying the syntax from the dataport gride, I get "< must not be the first word in a sentence"
    NormalSign -- Import::OnAfterAssignVariable()
    ----------------------------------------
    IF NormalSign = 'Negative' THEN <Payroll Journal Line>::Normal Sign := 0 ELSE" Normal Sign" := 1;
    

    So now that I can refer to the data value, how can I refer to the table/field??
  • Options
    deV.chdeV.ch Member Posts: 543
    You should be able to access the fields trough your first method "payroll journal line"."Normal Sign"
    I don't know why it doesn't work that way but i would try to rename the Datasource Variable to something without spaces : PayrollJournalLine(Payroll Journal Line)
  • Options
    kinekine Member Posts: 12,562
    Use the symbol menu to select correct record variable and the field. If you have element of type table, it must be on the list. Name depends on property of this element.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    ccbryan63ccbryan63 Member Posts: 115
    The answer: for the Nodes, as Kamil pointed out, you have to set the Source type to Text.

    For the table, the format is "<tablename>", thus:
    IF NormalSign = 'Negative' THEN "<Payroll Journal Line>"."Normal Sign" := 0 ELSE "<Payroll Journal Line>"."Normal Sign" := 1;
    

    Cheers everybody....
Sign In or Register to comment.