How to validate fields from a dataservice in DSS? - wso2

I'm making a data service but in a int field I need to validate that is not greater than 10 and less than 0.

When you are creating the field you can add the type of validation you decide, selecting the option to add validation, you need to select the option "Long Range Validation" and define minimum and maximum value that you want.
An example query where I use this validation, by default the minimum value is 0 so it is omitted.
<query id="1" useConfig="DS_FARMACY">
<sql>call getEmployeeById(?)</sql>
<result element="Employees" rowName="Employe">
<element column="id" name="Id" xsdType="integer"/>
<element column="Desc" name="Description" xsdType="string"/>
</result>
<param name="Id" paramType="SCALAR" sqlType="INTEGER" type="IN">
<validateLongRange maximum="10"/>
</param>
</query>
Review the WSO2 documentation where each option is specified to validate fields
http://wso2.com/project/data-services/2.6.3/docs/validation.html

Validators are added to individual input mappings in a query. Input validation allows data services to validate the input parameters in a request and stop the execution of the request if the input doesn’t meet required criteria. WSO2 Data Service Server provides a set of built-in validators for some of the most common use cases. It also provides an extension mechanism to write custom validators.
In this case you need select Long Range Validator to validate if an integer value is in the specified range. The validator requires a minimum and a maximum value to set the range. For example:

Related

WSO2 DSS return zero instead of null for some of null fields

There is a service made on wso2 dss based on query on a mssql view, my problem is that the service returns 0 value for some of null fields in database. It seams that 0 just returns for numeric values for example for below elements with same null value in db, GPANO returns as 0 and GPA return as a null tag:
<element column="GPANO" name="GPANO" xsdType="xs:string"/>
<element column="GPA" name="GPA" xsdType="xs:string"/>
This issue occurs when you have nullable numeric data types such as tinyInt, Int, ... in your database. So you should change your data service query like this:
select case when GPA is null then '' else GPA end as GPA, ...
This will solve your problem and you will not see 0 in your output.
This issue has been fixed in WSO2 DSS 3.5.0. you can use that distribution for your use case.

How to set min and max prices for products using Amazon MWS API

Is it possible to set the minimum-seller-allowed-price and maximum-seller-allowed-price prices of products via flat file AND submit it as a feed via the MWS API?
Sellers will have to specify a min and max price for all items from 15th Jan 2015 onwards viz:
"With effect from January 14, 2015, you will not be able to use the Seller Central preferences to select a blanket “opt-out” from all potential low and high-pricing error rules. The aim is to reduce price error risks to sellers and avoid potentially negative buyer experiences. Instead, you will need to set a minimum and maximum allowed selling price for each product in your inventory. If you do not chose pricing limits for each product, Amazon’s default potential pricing error rules will apply to your products...."
So, from reading "https://sellercentral-europe.amazon.com/gp/help/201141430" this implies that it can be done via a "Price & Quantity Inventory" file. However, the solution that I'm after needs to be done via the MWS API.
For normal price feeds, I'd set the feed type to _POST_PRODUCT_PRICING_DATA_ too.
I don't think that you can set the min and max prices via XML as the price feed XSD does not contain a definition for these fields (not that I can find anyway).
Sai.
Here is a small sample if you need for type _POST_PRODUCT_PRICING_DATA_ feed on mws (here it's for amazon.co.uk):
<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>YOUR_ID</MerchantIdentifier>
</Header>
<MessageType>Price</MessageType>
<Message>
<MessageID>1</MessageID>
<Price>
<SKU>YOUR_SKU</SKU>
<StandardPrice currency="GBP">30.75</StandardPrice>
<MinimumSellerAllowedPrice currency="GBP">20</MinimumSellerAllowedPrice>
<MaximumSellerAllowedPrice currency="GBP">40</MaximumSellerAllowedPrice>
</Price>
</Message>
</AmazonEnvelope>
Amazon provides this schema for their Price feed.
The MinimumSellerAllowedPrice and MaximumSellerAllowedPrice fields can be used to specify the min and max prices and they would look like this :
<MinimumSellerAllowedPrice currency="GBP">12.3</MinimumSellerAllowedPrice>
<MaximumSellerAllowedPrice currency="GBP">23.4</MaximumSellerAllowedPrice>
Be aware that if the currency is "EUR" you will have to specify the values for these 2 fields using comma :
<MinimumSellerAllowedPrice currency="EUR">11,1</MinimumSellerAllowedPrice>
Also note that the StandardPrice field should always be using dot for value representation, so 11.1 , even if the currency is "EUR".
#Stefan, not sure how to respond to your comment but below is an example of XML data that I send to update the price (MinimumSellerAllowedPrice = 24.94).
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>ABC123</MerchantIdentifier>
</Header>
<MessageType>Price</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Price>
<SKU>13182</SKU>
<StandardPrice currency="GBP">11.96</StandardPrice>
<MinimumSellerAllowedPrice currency="GBP">11.1</MinimumSellerAllowedPrice>
<MaximumSellerAllowedPrice currency="GBP">24.94</MaximumSellerAllowedPrice>
</Price>
</Message>
</AmazonEnvelope>
And for me, Amazon processes these requests without error, and so if you're getting error code 5000 in the response, contact Amazon support and send them your XML together with the response. They should get back to you with an answer.

Can I use regex in SharePoint GetListItems web service

I need to list all the files located in one document library that match a specific naming convention: The documents to retrieve are all in the form 'Report xxxx-xx-xx'.
I have to use the GetListItems web service.
Is there a way to collect all these documents in one call?
How to write the 'where' section in the query part?
Can I use some regex in this?
Thanks
Reading
http://msdn.microsoft.com/en-us/library/ms471093(v=office.12).aspx
http://msdn.microsoft.com/en-us/library/ms414805(v=office.12).aspx
the construction of a WHERE clause seems clear:
<Query>
<Where>
<Geq>
<FieldRef Name="Expires"/>
<Value Type="DateTime">
<Today/>
</Value>
</Geq>
</Where>
<OrderBy>
<FieldRef Name="Modified"/>
</OrderBy>
</Query>
However there does not seem to be a way to use regexes. Perhaps the best you can do is to use the BeginsWith element on the "Report" and Contains element to search for a dash. There is a good example for this at
http://msdn.microsoft.com/en-us/library/ms196501(v=office.12).aspx
Perhaps you could add a Calculated Column on your document library, that performs a string manipulation and/or test operation on your title text, and returns eg something that can then easily be picked up in your where clause?
This might help limit the result set at the server side...
=IF(LEFT([TitleColumn],7)="Report ", if(ISNUMBER(DATEVALUE(RIGHT([TitleColumn],10))), "TRUE", "FALSE"), "FALSE")
Refer to Microsoft's Calculated Field Formulas for what's available in calculated columns.

Searching Attachments in SharePoint 2010 Lists using CAML

I need help on searching attachments i.e Word Document, PDF etc which are attached to the list during inserting Item in SharePoint 2010 using CAML queries.
I tried with this query
<Query>
<Where>
<Eq>
<FieldRef Name="Attachments" />
<Value Type="Attachments">WordDocument1.docx</Value>
</Eq>
</Where>
</Query>
im not able to get any results if i give this query.
Please help.
The problem here is that the Attachments field of a SharePoint list does not store the attachments itself. This column only return whether a certain list item has an attachment or
not.
The attachments are not stored in a SharePoint list. Therefore I don't think it's possible to retrieve them with a CAML query.

Sharepoint Lists - GroupBy?

I'm trying to get data from a Sharepoint list and put it into some Flex graphs. I can call the list data just fine using a CAML query, but I want to use a GroupBy to consolidate the rows by Teams. So, for example Team 1 may have 20 records, Team 2 may have 8 records, and Team 3 might have 25 records... Instead of showing 53 records, I want to show 3... just "Team 1, Team 2, Team 3" and the sum of the cost of each entry.
I see where CAML provides a GroupBy element, but I can't seem to get it to work. Also, I was only able to get the OrderBy element to work when I used the OrderField element instead of the FieldRef element like 90% of the books and websites recommend. If I do use FieldRef, OrderBy doesn't work anymore, which makes no sense to me. Something must be awry...
Here is my CAML Query as it stands...
---------------------------------------------------
<queryRequest xmlns="http://schemas.microsoft.com/sharepoint/dsp">
<dsQuery resultContent="dataOnly" resultRoot="Rows" resultRow="Row" columnMapping="attribute">
<ViewFields>
<FieldRef Name="Team"></FieldRef>
<FieldRef Name="Cost"></FieldRef>
<FieldRef Name="EANo"></FieldRef>
</ViewFields>
<Query>
<GroupBy collapse="true">
<FieldRef Name="Team"/>
</GroupBy>
<OrderBy>
<OrderField Name="Cost"/>
</OrderBy>
</Query>
</dsQuery>
</queryRequest>
---------------------------------------------------
This is with OrderBy working, but GroupBy not working. Help!
Thanks!
I ran the following query and seems to be working fine for me.
<Query>
<GroupBy collapse="true">
<FieldRef Name='Date' />
</GroupBy>
<OrderBy>
<FieldRef Name='Title' />
</OrderBy>
</Query>
I suggest you use the U2U CAML Query Builder tool to build and test your query's