Fetching data from external XML with Alloy in Titanium - backbone.js

I'm working on my very first iPhone application made in Appcelerator Titanium. I'm using the Alloy framework.
I only have a general JavaScript background. I Have read up on how BackboneJS works, however I am struggling with the concept.
The app is very basic, all I need is to fetch an URL which contains a XML response. Example: http://www.domain.com/api.php?listProducts
This URL will respons something like this
<response>
<request>
<timestamp id="0.66266400 1357656226"/>
<status id="100">OK</status>
</request>
<api_function>getproductsimage</api_function>
<products>
<product id="1">
<images>
<image name="featured" width="640" height="347" src="../html/productImages/featured.jpg"/>
<image name="nonretina" width="125" height="95" src="../html/productImages/thumbnail.jpg"/>
<image name="retina" width="250" height="190" src="../html/productImages/thumbnail.jpg"/>
<image name="ldpi" width="" height="" src=""/>
<image name="mdpi" width="" height="" src=""/>
<image name="hdpi" width="" height="" src=""/>
<image name="xhdpi" width="" height="" src=""/>
</images>
</product>
</product>
</products>
</response>
I want to handle this data in a TableView and obviously there will be more than one response. However I don't really understand the documentation about making an XHR in BackboneJS. Would anyone be able to help me make a simple collection / model for simply fetching this URL and displaying the data.
Thanks in advance

is is purely a backbonejs Model parse issue since backbone works with JSON responses and you are looking at return XML.
There is no requirement that you use Alloy models to solve this problem so you can just implement your solution with http requests and populate the objects yourself.

Related

Implementing Sage Intacct API via Postman

I would like to get the invoice link from the purchase order implementing Sage Intacct API via Postman.
I suppose it can be done by following sequences(or by only one api request? not sure about this).
Order a purchase
Create a purchase receipt
Get an invoice link from it
Please refer to this API document (https://developer.intacct.com/api).
i.e. This is the body of a request to create a purchase transaction.
<?xml version="1.0" encoding="UTF-8"?>
<request>
<control>
<senderid>{{sender_id}}</senderid>
<password>{{sender_password}}</password>
<controlid>{{$timestamp}}</controlid>
<uniqueid>false</uniqueid>
<dtdversion>3.0</dtdversion>
<includewhitespace>false</includewhitespace>
</control>
<operation>
<authentication>
<sessionid>{{temp_session_id}}</sessionid>
</authentication>
<content>
<function controlid="{{$guid}}">
<create_potransaction>
<transactiontype>Purchase Requisition</transactiontype>
<datecreated>
<year>2013</year>
<month>6</month>
<day>19</day>
</datecreated>
<vendorid>1001</vendorid>
<referenceno>1234</referenceno>
<vendordocno>vendordocno001</vendordocno>
<datedue>
<year>2013</year>
<month>6</month>
<day>20</day>
</datedue>
<payto>
<contactname>Jameson Company</contactname>
</payto>
<exchratetype>Intacct Daily Rate</exchratetype>
<customfields/>
<potransitems>
<potransitem>
<itemid>75300GL</itemid>
<quantity>100</quantity>
<unit>Each</unit>
<price>1</price>
<locationid>MGMT-US</locationid>
<departmentid>IT</departmentid>
</potransitem>
</potransitems>
</create_potransaction>
</function>
</content>
</operation>
</request>
Thank you in advance.
You can download the Postman collection file (API) from the developer docs.
And then just refer to Purchasing/Purchasing Transactions/Create Transaction (Legacy).
You can change the body (SOAP) content.
I'm sure you can manage it.

Is it possible to create an integration cartridge for BM in the Saleforce for "Marchant Tools" using controllers, not pipelines?

I must create new cartridge for integration in BM but I don't want use pipelines. Can I use the controllers for this? If yes, please provide information on how to do this.
.
Yes, you can. You need to create the bm_extensions.xml and add all the actions/entries.
Note: The file mention pipeline but It can actually be a Controller as you can see in the example I linked below.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<extensions xmlns="http://www.demandware.com/xml/bmmodules/2007-12-11"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.demandware.com/xml/bmmodules/2007-12-11 bmext.xsd">
<menuaction id="paypal_transactions_manager" menupath="orders" position="200" site="true">
<name xml:lang="x-default">PayPal Transactions</name>
<short_description xml:lang="x-default">Manage the PayPal transactions related with this site orders.</short_description>
<description xml:lang="x-default">Manage the PayPal transactions related with this site orders.</description>
<exec pipeline="PaypalAdmin" node="Orders" />
<sub-pipelines>
<pipeline name="PaypalAdmin-Orders" />
<pipeline name="PaypalAdmin-OrderTransaction" />
<pipeline name="PaypalAdmin-Action" />
<pipeline name="PaypalAdmin-CreateNewTransaction" />
</sub-pipelines>
<icon>paypalbm/images/icon_transactions.png</icon>
</menuaction>
</extensions>
PayPal Cartridge bm_paypal is a good example to understand how is done: https://github.com/SalesforceCommerceCloud/link_paypal/tree/master/cartridges/bm_paypal/cartridge
Ps: Let me know if you cannot access the link.

Obout Suite Superform DateField issue

I am using the Obout Suite in a website.
I have a SuperForm control in which I have inserted some controls like BoundFields or DateFields.
The problem is that when I select a date at the DateField Calendar, the textbox associated doesn't refresh the value of the date.
I have something like:
<obout:SuperForm ID="SuperForm2" runat="server" AutoGenerateInsertButton ="true" AutoGenerateEditButton="false" AutoGenerateDeleteButton="false" AutoGenerateRows="false" DataKeyNames="IdDocumento" DefaultMode="Insert" Width="525" DataSourceID="SqlDataSource2">
<Fields>
<obout:BoundField DataField="DocumentType" HeaderText="Name" FieldSetID="FieldSet1" />
<obout:DateField DataField="OrderDate" HeaderText="Order Date" FieldSetID="FieldSet2" DataFormatString="{0:MM/dd/yyyy}" ApplyFormatInEditMode="true" />
<obout:DateField DataField="RequiredDate" HeaderText="Required Date" FieldSetID="FieldSet2" DataFormatString="{0:MM/dd/yyyy}" ApplyFormatInEditMode="true" />
</Fields>
<FieldSets>
<obout:FieldSetRow>
<obout:FieldSet ID="FieldSet1" />
</obout:FieldSetRow>
<obout:FieldSetRow>
<obout:FieldSet ID="FieldSet2" />
</obout:FieldSetRow>
</FieldSets>
</obout:SuperForm>
The tag prefix is:
<%# Register TagPrefix="obout" Namespace="Obout.SuperForm" Assembly="obout_SuperForm" %>
The "obout_Calendar2_Net.dll" is referenced by the solution.
Am I forgotting something?
Thanks in advance.
Cartojal
Well, finally I found the solution. If you are using .net 4.0, like me.... you must to add the attribute clientIDMode="AutoID" to the section "pages" at the web.config file:
<pages clientIDMode="AutoID">
....
</pages>
This generate the asp.net controls ids like past versions of .net

iReport, how to print fields of different table

I need multiple queries in my report so i added a new dataset.
The problem is i can't use fields of new dataset in my report, the error is: field does not exists.
So, how can i have multiple query in my report(to print fields of different table) without create a subreport for each field?
Thanks.
Unfortunately this isn't how iReport works. You need to get all your data into one dataset to use the fields side by side. See #GenericJon's detailed answer on using a datasetRun where your fields are used as input parameters to define another dataset.
If you really want the parameters can be used to pass a field for output in a datasetRun. This outputs Dataset1>Field1 / Dataset2>Field2.
<subDataset name="TotalUsers">
<parameter name="Users" class="java.lang.Integer" isForPrompting="false"/>
<parameter name="Date" class="java.util.Date" isForPrompting="false"/>
<queryString language="SQL">
<![CDATA[CALL GetTotalUsersAtDate($P{Date})]]>
</queryString>
<field name="TotalUsers" class="java.lang.Long"/>
</subDataset>
...
<componentElement>
<reportElement x="0" y="78" width="555" height="16"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="TotalUsers">
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<datasetParameter name="Users">
<datasetParameterExpression><![CDATA[$F{MusicSubscribers}]]></datasetParameterExpression>
</datasetParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:listContents height="16" width="555">
<textField pattern="#,##0.00 %" isBlankWhenNull="true">
<reportElement style="table_TD" x="475" y="0" width="80" height="16"/>
<textElement/>
<textFieldExpression><![CDATA[$P{Users}.doubleValue()/$F{TotalUsers}.doubleValue()]]></textFieldExpression>
</textField>
<staticText>
<reportElement style="table_TD" x="0" y="0" width="475" height="16"/>
<textElement textAlignment="Left" markup="none"/>
<text><![CDATA[Proportion of total users]]></text>
</staticText>
</jr:listContents>
</jr:list>
</componentElement>
I would go further to suggest you do as much of the math and collating outside of iReport too, i.e. use stored procedures if your data source is a database.

SQL Server FOR XML adding in a tag

So I am pulling data from a SQL Server 2000 DB then converting it to XML using FOR XML AUTO.
The XML I get back looks like this.
<Order OrderNumber="2000004" DeliveryPickupCharge="5.9900" SalesTaxTotal="0.0000" SubTotal="0.0000" Total="5.9900">
<Customer FirstName="Anthony" LastName="Caporale">
<Product ProductName="Paper Towels">
<OrderItem ItemQuantity="1" ItemPrice="8.5900" Total="8.5900" />
</Product>
<Product ProductName="Bathroom Tissue - Giant Roll">
<OrderItem ItemQuantity="2" ItemPrice="7.1500" Total="14.3000" />
</Product>
<Product ProductName="Napkins - 1-Ply">
<OrderItem ItemQuantity="1" ItemPrice="3.4900" Total="3.4900" />
</Product>
<Product ProductName="Facial Tissues - 2-Ply - White">
<OrderItem ItemQuantity="2" ItemPrice="2.0500" Total="4.1000" />
</Product>
<Product ProductName="Anti-Perspirant & Deodorant - Ultra DryCool Rush">
<OrderItem ItemQuantity="2" ItemPrice="3.5900" Total="7.1800" />
</Product>
<Product ProductName="Flushable Wipes - Fresh Mates Cloths - Refill">
<OrderItem ItemQuantity="2" ItemPrice="2.9500" Total="5.9000" />
</Product>
Firstly, in 2000 there is no Root('whatever'), so is there any way to add a root node in the T-SQL? Also, is there a way to wrap all the products in a products tag? I don't quite get why the XML returned is in such bad form. I could fix it up a little if I was in SQL 2005. Unfortunately, I am stuck with 2000 at the moment.
Thanks
You can manipulate the XML to your wish with the FOR XML EXPLICIT mode. I reckon is way way more complex than AUTO (or the 2k5 PATH) but it works fine once you get it going.
I know in 2005 using nested selects allows you to embed multiple results in one core tag (multiple Product in Products) with the ensted seelect also being declared for XML AUTO.
You could also use this technique to wrap everything in a root tag by using one large nested select.

Resources