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?

North52 has a powerful distributed cache for advanced decision logic

xCache allows you to configure and scale your Dynamics 365/CRM applications running On-Premise or Online. It allows dynamic system configuration and removes performance bottlenecks related to data storage. xCache provides Dynamics 365/CRM with an extremely fast and scalable distributed cache to power your advanced decision logic.

xCache in Dynamics CRM  lets you cache static application data, and also load dynamic cache items for applications running in a single or multi-server configuration.

Learn more and see examples of xCache