reuse proxy call data for extjs store - extjs

I have a xml that i need to bind to XTemplate. The XML structure is as follows
<Name>
<Student_Name>
<First>John</First>
<Last>Smith</Last>
</Student_Name>
<Student_Name>
<First>John</First>
<Last>Doe</Last>
</Student_Name>
<Faculty_Name>
<First>Johny</First>
<Last>Byrd</Last>
</Student_Name>
</Name>
I am using Ext.data.Store with proxyurl tot he xml, Ext.data.XML reader to rad the xml and a listener that bind the data to the Xtemplate.
The xmlreader needs a root node to be specified and i have to give root name as "Student_Name"
It need to bind it to one more store for "Faculty_Name" as the root node. SO i end up calling my service to get xml twice. Is there a way to call service once to get the xml and bind it to two stores with different root nodes.

At the risk of sounding like Captain Obvious, you actually need 2 root nodes in your data. I would also suggest renaming your nodes (if possible) to eliminate redundancy and make your XML more semantically logical, e.g.,
<People>
<Students>
<Name>
<First>John</First>
<Last>Smith</Last>
</Name>
<Name>
<First>John</First>
<Last>Doe</Last>
</Name>
</Students>
<Faculty>
<Name>
<First>Johny</First>
<Last>Byrd</Last>
</Name>
</Faculty>
</People>
That way Students and Faculty can be your 2 separate root nodes and you'll only need a single server call.

Related

The createdFrom field on NetSuite Invoice is not populating when using SOAP Web Services via Workato

I am using Workato for my Salesforce to NetSuite integration and everything works perfectly with the exception of populating the createdFrom field on the Invoice record. Has anyone been successful in linking the NetSuite Invoice to its associated Sales Order using Web Services? This is critical as the linkage ensures that Revenue Arrangements are not duplicated in NetSuite.
I do not have first hand experience with SOAP Web Services but have seen via SuiteScript 2.x that one cannot simply create the record and try to fill in the createdFrom field. You must rather "transform" a Sales Order into an Invoice for example. The "transformation" is what links the two. Looks like for SOAP the operation is named "initialize / initializeList". The SOAP web services initialize operation emulates the UI workflow by prepopulating fields on transaction line items with values from a related record. Reference Suite Answer 10771 for more information. Suite Answer 91358 also has some sample code.
yes I have created invoices from Sales Order using SOAP Webservices. I am using minimum number of required fields to create the invoice.
Here is the endpoint URL that I used : https://(insert your account Id here).suitetalk.api.netsuite.com/services/NetSuitePort_2020_1
Note 1: You need to make sure that the version is consistent through out your SOAP request (in my case it's 2020_1)
Note 2: You can see that I am passing createdFrom tag as second last tag and I am passing Sales order's internal ID there. That means that invoice is being generated from that particular sales order and it carries over rest of the fields from sales order
Note 3: I am passing externalid of the invoice at the end which will the unique id of this newly created invoice across different systems
Please let me know how this goes!
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:messages="urn:messages_2020_1.platform.webservices.netsuite.com" xmlns:accountingLists="urn:accounting_2020_1.lists.webservices.netsuite.com" xmlns:employeesLists="urn:employees_2020_1.lists.webservices.netsuite.com" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:employeesTransactionsTypes="urn:types.employees_2020_1.transactions.webservices.netsuite.com" xmlns:demandplanningTransactions="urn:demandplanning_2020_1.transactions.webservices.netsuite.com" xmlns:common="urn:common_2020_1.platform.webservices.netsuite.com" xmlns:commonTypes="urn:types.common_2020_1.platform.webservices.netsuite.com" xmlns:accountingListsTypes="urn:types.accounting_2020_1.lists.webservices.netsuite.com" xmlns:customizationSetup="urn:customization_2020_1.setup.webservices.netsuite.com" xmlns:inventoryTransactionsTypes="urn:types.inventory_2020_1.transactions.webservices.netsuite.com" xmlns:supportLists="urn:support_2020_1.lists.webservices.netsuite.com" xmlns:filecabinetDocuments="urn:filecabinet_2020_1.documents.webservices.netsuite.com" xmlns:bankTransactionsTypes="urn:types.bank_2020_1.transactions.webservices.netsuite.com" xmlns:communicationGeneralTypes="urn:types.communication_2020_1.general.webservices.netsuite.com" xmlns:customizationSetupTypes="urn:types.customization_2020_1.setup.webservices.netsuite.com" xmlns:supplychainListsTypes="urn:types.supplychain_2020_1.lists.webservices.netsuite.com" xmlns:core="urn:core_2020_1.platform.webservices.netsuite.com" xmlns:coreTypes="urn:types.core_2020_1.platform.webservices.netsuite.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:supplychainLists="urn:supplychain_2020_1.lists.webservices.netsuite.com" xmlns:demandplanningTransactionsTypes="urn:types.demandplanning_2020_1.transactions.webservices.netsuite.com" xmlns:websiteLists="urn:website_2020_1.lists.webservices.netsuite.com" xmlns:salesTransactions="urn:sales_2020_1.transactions.webservices.netsuite.com" xmlns:salesTransactionsTypes="urn:types.sales_2020_1.transactions.webservices.netsuite.com" xmlns:relationshipsLists="urn:relationships_2020_1.lists.webservices.netsuite.com" xmlns:inventoryTransactions="urn:inventory_2020_1.transactions.webservices.netsuite.com" xmlns:employeesListsTypes="urn:types.employees_2020_1.lists.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:customersTransactions="urn:customers_2020_1.transactions.webservices.netsuite.com" xmlns:schedulingActivitiesTypes="urn:types.scheduling_2020_1.activities.webservices.netsuite.com" xmlns:financialTransactions="urn:financial_2020_1.transactions.webservices.netsuite.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:relationshipsListsTypes="urn:types.relationships_2020_1.lists.webservices.netsuite.com" xmlns:employeesTransactions="urn:employees_2020_1.transactions.webservices.netsuite.com" xmlns:faults="urn:faults_2020_1.platform.webservices.netsuite.com" xmlns:marketingListsTypes="urn:types.marketing_2020_1.lists.webservices.netsuite.com" xmlns:communicationGeneral="urn:communication_2020_1.general.webservices.netsuite.com" xmlns:faultsTypes="urn:types.faults_2020_1.platform.webservices.netsuite.com" xmlns:supportListsTypes="urn:types.support_2020_1.lists.webservices.netsuite.com" xmlns:websiteListsTypes="urn:types.website_2020_1.lists.webservices.netsuite.com" xmlns:purchasesTransactions="urn:purchases_2020_1.transactions.webservices.netsuite.com" xmlns:financialTransactionsTypes="urn:types.financial_2020_1.transactions.webservices.netsuite.com" xmlns:schedulingActivities="urn:scheduling_2020_1.activities.webservices.netsuite.com" xmlns:bankTransactions="urn:bank_2020_1.transactions.webservices.netsuite.com" xmlns:marketingLists="urn:marketing_2020_1.lists.webservices.netsuite.com" xmlns:customersTransactionsTypes="urn:types.customers_2020_1.transactions.webservices.netsuite.com" xmlns:purchasesTransactionsTypes="urn:types.purchases_2020_1.transactions.webservices.netsuite.com" xmlns:generalTransactions="urn:general_2020_1.transactions.webservices.netsuite.com" xmlns:filecabinetDocumentsTypes="urn:types.filecabinet_2020_1.documents.webservices.netsuite.com">
<soap:Header>
<urn:tokenPassport xmlns:urn="urn:messages_2020_1.platform.webservices.netsuite.com">
<ns8:account xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com">XXX</ns8:account>
<ns8:consumerKey xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com">XXX</ns8:consumerKey>
<ns8:token xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com">XXX</ns8:token>
<ns8:nonce xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com">XXX</ns8:nonce>
<ns8:timestamp xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com">XXX</ns8:timestamp>
<ns8:signature xmlns:ns8="urn:core_2020_1.platform.webservices.netsuite.com" algorithm="HMAC_SHA256">XXX</ns8:signature>
</urn:tokenPassport>
<preferences xmlns="urn:messages_2020_1.platform.webservices.netsuite.com"/>
</soap:Header>
<soap:Body>
<add>
<record xmlns:salesTransactions="urn:sales_2020_1.transactions.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="salesTransactions:Invoice">
<itemList>
<item xsi:type="salesTransactions:InvoiceItem">
<orderLine xsi:type="salesTransactions:long">1</orderLine>
<quantity xsi:type="salesTransactions:double">1</quantity>
<rate xsi:type="salesTransactions:string">30000</rate>
<description xsi:type="salesTransactions:string">Annuity test</description>
</item>
</itemList>
<tranDate xsi:type="salesTransactions:dateTime">2020-09-09T00:00:00.000</tranDate>
<createdFrom xmlns:core="urn:core_2020_1.platform.webservices.netsuite.com" xsi:type="core:RecordRef" internalId="33202933"/>
<externalId xmlns:core="urn:core_2020_1.platform.webservices.netsuite.com" xsi:type="core:RecordRef">INV000089099</externalId>
</record>
</add>
</soap:Body>
</soap:Envelope>

Having an issue with XML containing nested objects to POCO (de)serialisation (VB.Net)

I've created an SP in SQL Server that returns as XML. I decided to do this as the information has contacts and addresses in it and I wanted to reduce the amount of data I get.
<Accounts>
<Account>
<Company />
<ContactNumber />
<Addresses>
<Address>
<Line1 />
....
</Address>
<Addresses>
<Contacts>
<Contact>
<Name />
....
</Contact>
<Account>
</Accounts>
I have found SqlCommand.ExecuteXmlReader but I'm confused as to how to serialise this into my POCO. Can someone point me at what my next step is. (The POCO was created by the Insert XML as a class menu item in VS2019).
My Google fu is letting me down as I'm not sure what I should be looking for to help understand how to serialize the XML into something that will allow me to go with Foreach Account in AccountsClass type logic.
Any help is greatly appreciated.
PS The XML above is just a sample to show what I'm doing. The actual data is over 70 fields and with two FK joins the initial 40000 rows is well in excess of 1.8 million once selected as a normal dataset.
EDIT: Just in case someone stumbles on this and are in the same situation I was in.
When preparing a sample record for the Past XML to class make sure you have more than one record if you are expecting something similar to my example above. (The class changes to support more than one record.)
You get very different results when searching for deserialize when doing your research. This small change resulted in me figuring out the issue.

Stored procedure mapping for many-to-many association

I have a relatively simple table of Terms, and each Term can have multiple parents and children so there is a TermAssociation table.
Term TermAssociation
---- ---------------
TermID ParentTermID
TermName ChildTermID
...
When mapped in EF, this generates a Term entity with a many-to-many association with itself. Everything's cool.
The problem is I work in an environment where all table updates must go through stored procedures. I can use stored procedure mapping just fine for the Term entity, but how do I map an SP to the TermAssociation table since it's modeled as an association and not an entity?
I haven't found a way to do this through the designer, but it is possible if you edit the XML of the edmx file directly. Find the association set mapping:
<AssociationSetMapping Name="TermAssociation" TypeName="TCPDataDictionaryModel.TermAssociation" StoreEntitySet="TermAssociation">
<EndProperty Name="Term">
<ScalarProperty Name="TermId" ColumnName="ParentTermId" />
</EndProperty>
<EndProperty Name="Term1">
<ScalarProperty Name="TermId" ColumnName="ChildTermId" />
</EndProperty>
</AssociationSetMapping>
Then add a ModificationFunctionMapping inside the AssociationSetMapping. InsertAssociation is my insert SP and it takes #ParentTermId and #ChildTermId as parameters.
<ModificationFunctionMapping>
<InsertFunction FunctionName="TCPDataDictionaryModel.Store.InsertAssociation" >
<EndProperty Name="Term">
<ScalarProperty Name="TermId" ParameterName="ParentTermId" />
</EndProperty>
<EndProperty Name="Term1">
<ScalarProperty Name="TermId" ParameterName="ChildTermId" />
</EndProperty>
</InsertFunction>
</ModificationFunctionMapping>

XML AUTO is creating nested element

my xml:auto is creating nested element on performing join so i want to remove nested node of other table..
<fo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ss.dbo.FO>
<aa>10</aa>
<bb>120</bb>
<cc>([ads]{})})</cc>
<stds.dbo.IR>
<dd>Upmp</dd>
</ss.dbo.DIR>
</ss.dbo.FO>
use the XML:ROW in place of XML:AUTO to Solve this problem XML:AUTO is generating automatic xml for the sql query if you use xml:r--row it will genrate but in simple format without any nested values-- – PANKAJ 786 Dec 13 at 10:39

SQL Server XQuery with Default Namespace

I've got some XML Data in a SQL Server Table in an XML Column as follows:
<AffordabilityResults>
<matchlevel xmlns="urn:callcredit.co.uk/soap:affordabilityapi2">IndividualMatch</matchlevel>
<searchdate xmlns="urn:callcredit.co.uk/soap:affordabilityapi2">2013-07-29T11:20:53</searchdate>
<searchid xmlns="urn:callcredit.co.uk/soap:affordabilityapi2">{E40603B5-B59C-4A6A-92AB-98DE83DB46E7}</searchid>
<calculatedgrossannual xmlns="urn:callcredit.co.uk/soap:affordabilityapi2">13503</calculatedgrossannual>
<debtstress xmlns="urn:callcredit.co.uk/soap:affordabilityapi2">
<incomedebtratio>
<totpaynetincome>0.02</totpaynetincome>
<totamtunsecured>0.53</totamtunsecured>
<totamtincsec>0.53</totamtincsec>
</incomedebtratio>
</debtstress>
</AffordabilityResults>
You'll note that some of the elements have an xmlns attribute and some don't...
I need to write queries to return the data - and more importantly show a business analyst how to write her own queries to get the data she needs so I want it to be as simple as possible.
I can query the data easily using the WITH XMLNAMESPACES element as follows:
WITH XMLNAMESPACES (N'urn:callcredit.co.uk/soap:affordabilityapi2' as x )
SELECT
ResponseXDoc.value('(/AffordabilityResults/x:matchlevel)[1]','varchar(max)' ) AS MatchLevel
, ResponseXDoc.value('(/AffordabilityResults/x:debtstress/x:incomedebtratio/x:totamtunsecured)[1]','nvarchar(max)' ) AS UnsecuredDebt
FROM [NewBusiness].[dbo].[t_TacResults]
But adding the x: part to the query makes it look overly complicated, and I want to keep it simple for the business analyst.
I tried adding:
WITH XMLNAMESPACES (DEFAULT 'urn:callcredit.co.uk/soap:affordabilityapi2' )
and removing the x: from the XQuery - but this returns null (possibly because of the lack of the xmlns on the root element?)
Is there any way I can simplify these queries either with or without the default namespace?
If namespaces are not important in your use case, you could use the namespace wildcard selector *:, which both selects nodes without and with arbitrary namespaces.
An example query could be
(/*:AffordabilityResults/*:matchlevel)[1]
The business analyst will still have to add the selector in front of every node test, but it's the same "prefix" all the time and the only error to be expected is forgetting to use it somewhere.

Resources