Views:

Basic XML Document creation

CreateXmlRootNode('Account','', '',
                   CreateXmlElement('AccountName', [account.name]),  
                   CreateXmlElement('AccountNumber', [account.accountnumber]),
                   CreateXmlElement('Address_Line1', [account.address1_line1]),  
                   CreateXmlElement('Address_Line2', [account.address1_line2]), 
                   CreateXmlElement('Address_Line3', [account.address1_line3]), 
                   CreateXmlElement('Address_City', [account.address1_city]),  
                   CreateXmlElement('Address_Zip', [account.address1_postalcode]),  
                   CreateXmlElement('Address_State', [account.address1_stateorprovince]),  
                   CreateXmlElement('Address_Country', [account.address1_country]) 
             )

How to add defaults on elements & sub-elements

CreateXmlRootNode('Account','','',
    CreateXmlElement('AccountName', [account.name], ''), 
    CreateXmlElement('AccountNumber', [account.accountnumber], ''), 
    CreateXmlElement('Address_Line1', [account.address1_line1], ''), 
    CreateXmlElement('Address_Line2', [account.address1_line2], ''), 
    CreateXmlElement('Address_Line3', [account.address1_line3], ''), 
    CreateXmlElement('Address_City', [account.address1_city], ''), 
    CreateXmlElement('Address_Zip', [account.address1_postalcode], ''), 
    CreateXmlElement('Address_State', [account.address1_stateorprovince], ''), 
    CreateXmlElement('Address_Country', [account.address1_country], ''),
    CreateXmlElement('MarketingData', 
              CreateXmlElement('DoNotBulkMail', [account.donotbulkemail]),
              CreateXmlElement('DoNotBulkPostalMail', [account.donotbulkpostalmail]),
              CreateXmlElement('DoNotEmail', [account.donotemail]),
             CreateXmlElement('DoNotFax', [account.donotfax]), 
              CreateXmlElement('DoNotPostalMail', [account.donotpostalmail]),
              CreateXmlElement('DoNotPhone', [account.donotphone])
             )
)

How to add XML attributes on an element

CreateXmlRootNode('Account','','',
    CreateXmlElement('AccountName', [account.name], ''), 
    CreateXmlElement('AccountNumber', [account.accountnumber], ''), 
    CreateXmlElement('Address_Line1', [account.address1_line1], ''), 
    CreateXmlElement('Address_Line2', [account.address1_line2], ''), 
    CreateXmlElement('Address_Line3', [account.address1_line3], ''), 
    CreateXmlElement('Address_City', [account.address1_city], ''), 
    CreateXmlElement('Address_Zip', [account.address1_postalcode], ''), 
    CreateXmlElement('Address_State', [account.address1_stateorprovince], ''), 
    CreateXmlElement('Address_Country', [account.address1_country], ''),
    CreateXmlElement('MarketingData', 
              CreateXmlElement('DoNotBulkMail', [account.donotbulkemail],  '', 
                                             CreateXmlAttribute('flag1','abc'), CreateXmlAttribute('flag2','123')),
              CreateXmlElement('DoNotBulkPostalMail', [account.donotbulkpostalmail],  '', 
                                            CreateXmlAttribute('flag1','abc'), CreateXmlAttribute('flag2','123')),
              CreateXmlElement('DoNotEmail', [account.donotemail],  '', 
?                                          CreateXmlAttribute('flag1','abc'), CreateXmlAttribute('flag2','123')),
             CreateXmlElement('DoNotFax', [account.donotfax],  '', 
                                             CreateXmlAttribute('flag1','abc'), CreateXmlAttribute('flag2','123')), 
              CreateXmlElement('DoNotPostalMail', [account.donotpostalmail],  '', 
                                              CreateXmlAttribute('flag1','abc'), CreateXmlAttribute('flag2','123')),
              CreateXmlElement('DoNotPhone', [account.donotphone],  '', 
                                             CreateXmlAttribute('flag1','abc'), CreateXmlAttribute('flag2','123'))
             )
)

How to add child nodes


CreateXmlRootNode('Account','','',
    CreateXmlElement('AccountName', [account.name], ''), 
    CreateXmlElement('AccountNumber', [account.accountnumber], ''), 
    CreateXmlElement('Address_Line1', [account.address1_line1], ''), 
    CreateXmlElement('Address_Line2', [account.address1_line2], ''), 
    CreateXmlElement('Address_Line3', [account.address1_line3], ''), 
    CreateXmlElement('Address_City', [account.address1_city], ''), 
    CreateXmlElement('Address_Zip', [account.address1_postalcode], ''), 
    CreateXmlElement('Address_State', [account.address1_stateorprovince], ''), 
    CreateXmlElement('Address_Country', [account.address1_country], ''),
    CreateXmlElement('MarketingData', 
              CreateXmlElement('DoNotBulkMail', [account.donotbulkemail]),
              CreateXmlElement('DoNotBulkPostalMail', [account.donotbulkpostalmail]),
              CreateXmlElement('DoNotEmail', [account.donotemail]),
             CreateXmlElement('DoNotFax', [account.donotfax]), 
              CreateXmlElement('DoNotPostalMail', [account.donotpostalmail]),
              CreateXmlElement('DoNotPhone', [account.donotphone])
             ),
    CreateXmlChildren('Contacts', 
              'Contact',
              FindRecords('contact', 'parentcustomerid', [account.accountid], '*' ),
              CreateXmlElement('FullName', FindXmlItem('fullname')),
             CreateXmlElement('JobTitle', FindXmlItem('jobtitle')), 
              CreateXmlElement('Email', FindXmlItem('emailaddress1')),
              CreateXmlElement('BusinessPhone', FindXmlItem('telephone1'))
             )
)

Did you know?

It is Faster, Easier and Smarter using North52

We help you deliver Dynamics 365 projects with complex decision logic/business rules:

FASTER.

Our no code business rules engine helps deliver CRM/CDS projects up to 10 times faster than using custom code.

EASIER.

Simple to use point-and-click interface to build simple or complex business rules.

SMARTER.

Lower your project risk and slash ongoing maintenance costs.

Learn more about the North52 Decision Suite