import { CRMClient } from "./src/CRMClient" ; import { DataTable } from "./src/DataTable" ; import { DataTableSerializer } from "./src/DataTableSerializer" ; var crm = new CRMClient ( "Url=http://crm.contoso.com/xrmContoso" ) ; var who = crm . whoAmI ( ) ; console . log ( who ) ; var myUser = crm . retrieve ( "systemuser" , who ) ; console . log ( myUser ) ; var account1 = crm . retrieve ( "account" , "4C1ECDF4-633B-E211-9EB5-0050568A69E2" , [ "accountid" , "name" , "ownerid" , "createdon" ] ) ; console . log ( account1 ) ; var account2 = crm . retrieve ( "account" , "4C1ECDF4-633B-E211-9EB5-0050568A69E2" ) ; console . log ( account2 ) ; var guid = crm . create ( "account" , { name : "test account" , description : "this is a test" } ) ; console . log ( "created account with id " + guid ) ; crm . delete ( "account" , guid ) ; for ( var i = 0 ; i < 10 ; i ++ ) { guid = crm . create ( "account" , { name : "test account " + i , description : "this is a test" , AccountCategoryCode : 1 } ) ; console . log ( "created account with id " + guid ) ; crm . delete ( "account" , guid ) ; } var accounts = DataTableSerializer . load ( "accounts.xml" ) ; var contacts = DataTableSerializer . load ( "contacts.xml" ) ; crm . update ( "account" , { accountid : "2ad7a34f-11db-4910-8f1c-397b1352f0e3" , name : "updated" } ) ; crm . update ( "account" , { name : "updated" } , { name : { like : "%test%" } } ) ; var dn = require ( "dynamicsnode" ) ; crm = new dn . CRMClient ( "UAT" ) ; var entityName = "account" ; var metadata = crm . getEntityMetadata ( entityName ) ; var outputTable = new dn . DataTable ( ) ; for ( var i = 0 ; i < metadata . Attributes . length ; i ++ ) { var attr = metadata . Attributes [ i ] ; outputTable . rows . push ( { name : attr . LogicalName , type : attr . AttributeType } ) ; console . log ( attr . LogicalName ) ; } dn . DataTableSerializer . save ( outputTable , `${ entityName }Attributes.xlsx` ) ;