Workflow conditions on a choice field type (Checkboxes (allow multiple selections)) in SharePoint 2010 - sharepoint-2010

I want to check the value of a choice column type that allows multiple selections. Basically;
If Current Item: Sports equals Hockey
Do something.....
If Current Item: Sports equals Baseball
Do something.....
If Current Item: Sports equals Football
Do something.....
If Current Item: Sports equals Basketball
Do something.....
Based on each item checked, when the condition is met the code execute for each item selected. I tried the obvious which looks just like the code I posted above.
Thank you

Answered my own question by experimenting a little more. If I have all options selected, Hockey, Baseball, Football, and Basketball, the Current Item value "Sports" will look like this
String: ;#Hockey;#Baseball;#Basketball;#Football;#
Choices, comma delimitted: Hockey, Baseball, Football, Basketball
So if I write my workflow this way;
If Current Item: Sports contains Hockey
Do something.....
If Current Item: Sports contains Baseball
Do something.....
If Current Item: Sports contains Football
Do something.....
If Current Item: Sports contains Basketball
Do something.....
if the value is selected , I am able to search the "array" or list items and execute the condition based on if the option is contained or not.
Thought I would post my answer in case it helps somebody else out. There are more complicated solutions online, but this one is simple and works well for me

Related

Ebay API - How To Determine Shipping Locations From FindItemsByCategory?

I'm retrieving all used buy-it-now camera and lenses from
EBAY-AT, EBAY-CH, EBAY-DE, EBAY-ES, EBAY-FR, EBAY-FRBE, EBAY-GB, EBAY-IE, EBAY-IT, EBAY-NL, EBAY-NLBE, EBAY-PL and EBAY-US
My 'customers' will come from all over Europe and the United States
I want to show them products which offer delivery to their country regardless of which EBAY site it originates.
https://developer.ebay.com/DevZone/finding/CallRef/findItemsByCategory.html#findItemsByCategory
shipToLocations - An international location or region to which the seller is willing to ship the item. Only returned when the seller has specifically identified locations where she is willing to ship the given item. specified.
https://developer.ebay.com/DevZone/finding/CallRef/Enums/shipToLocationList.html
This lists the possible values for the shipToLocation
However the API calls all come back with 'Worldwide' for shipToLocation, however this is just not true as I checked some which say are ship to just UK, Europe or even collection only.
What other options are there?

Fastest way to return a list of records depending on many many-to-many relationships

I'm developing an API in Rails in which exists users and messages tables. Also users have a gender (gender_id), belong to a country (country_id) and also have a civil status (civil_status_id) and the messages are created by admins.
So up to here I have this model.
Now I have to develop the following requirement
An admin should be able to create a message targeted to users depending on its attributes (country, gender or civil status). Also, the admin should be able to declare a message as a global message, in this case "all" users should receive it, but exceptions should also be allowed. For example, in the case where an admin want to send a message to users from all countries, except people from Russia and China.
The thing is I'm no Rails/SQL expert, but I want to make this efficiently so that if tomorrow the app has ten thousand or a hundred thousand users the server responds quickly.
So I was thinking the following
First create 3 many-to-many relationships (countries_messages, genders_messages and civil_statuses_messages). The record of these tables represent the relations between the messages and the countries, civil_statuses and genders.
Then create a form where an admin can create a message, where by means of several select boxes, he should be able to choose the attributes of the users to whom he wants to reach. The form for creating a message should also have a checkbox to determine if the message is global, if its marked then I would consider that the selected countries, genders and civil statuses would be the categories that the administrator wants to exclude, i.e. if an admin want to send a message to all the people in the system except for people who are from Canada he should mark the global option and select the country Canada in the select box (obviously this would be stated in the view).
Now up to here I have this model.
In what I do have doubts is which way is more efficient to return the messages that corresponds to a user.
Method 1
When an admin specifies that a message is global, except for those from country with id 3 then I could add to countries_messages records like (country_id: 1, message_id: 2), (country_id: 2, message_id: 2), (country_id: 4, message_id: 2), ..., etc. i.e. forming a relation with every country except the country with id 2.
Then retriveng the messages that the current user should read like the following:
global_messages = Message.where(global: true).ids
country_messages = current_user.country.messages.ids
gender_messages = current_user.gender.messages.ids
civil_status_messages = current_user.current_status.messages.ids
#messages = Message.find(global_messages + country_messages + gender_messages + civil_status_messages)
Method 2
Other way could be forming a relation of that message with the excluded country, i.e. if I make a message exclusively for people from country with id 2 then I should add the record (country_id: 2, message_id: 2) in countries_messages, but in the contrary case if I made a message to every country except the country with id 2 then I should also add the record (country_id: 2, message_id: 2) to countries_messages.
In this case I can know if a message is excluded for males and people from Argentina, for example, if the message is global AND it's associated with the country and gender record that represents Argentina and males.
Then the retriveng of the messages that the current user should read would be like this:
global_messages = Message.where(global: true).ids
country_messages = current_user.country.messages
gender_messages = current_user.gender.messages
civil_status_messages = current_user.current_status.messages
excluded_country_messages_ids = country_messages.where(global: true).ids
excluded_gender_messages_ids = gender_messages.where(global: true).ids
excluded_civil_status_messages_ids = civil_status_messages.where(global: true).ids
#messages = Message.find(global_messages + country_messages + gender_messages + civil_status_messages - excluded_country_messages_ids - excluded_gender_messages_ids - excluded_civil_status_messages_ids)
There could be more ways to do the same, so I want to receive recommendations or if you see that I could make improvements to do the same then tell me. If there is something you do not understand ask.
Depending on your database choice, you may want to consider storing the message "attributes" (country, gender, ...) in a jsonb column on your messages table. It could also include a user_ids attribute to simplify things. The queries might look a little funny, but you can move a lot into scopes to clear things up in your code and even add indexes to speed things up.
Here is a great article on using jsonb with indexes in Rails with postgresql.
Another alternative you could do is make a UserMessage join table with a polymorphic reference that could associate the different attributes to a message and user:
class UserMessage < ApplicationRecord
belongs_to :user
belongs_to :message
belongs_to :messageable_type # e.g. "Country"
belongs_to :messageable_id # e.g. some Country id
end

Has anyone gotten Kimono meta APIs to combine results from multiple APIs?

The documentation describes a meta collection as a combination of 2 (or more) different APIs...
By default, a meta API endpoint returns all data from all of its
sub-APIs, organized by collection.
But, what I find is that it does not do this. It grabs partial data from some sub-APIs and fails silently, without logging an error.
API #1 Result
COLLECTION2
ROW LIST.HREF LIST.TEXT INDEX URL
1 http:/​/​www.amazon.com/​Org...pollux+​organix+​canned+​dog Canned Dog Food 3 http:/​/​www.austinpetsalive.org/​donate/​wish-​list/​
2 http:/​/​www.amazon.com/​Pre...s-​Large/​lm/​R34ISSXSRJPA71 Premier Brand Martingale collars (Pink, Silver, Blue, Red, and Orange) sizes XL or L 4 http:/​/​www.austinpetsalive.org/​donate/​wish-​list/​
3 http:/​/​www.amazon.com/​Pre...ords=​medium+​gentle+​leader Medium & Large Gentle Leaders 5 http:/​/​www.austinpetsalive.org/​donate/​wish-​list/​
API #2 Result
COLLECTION2
ROW LIST.HREF LIST.TEXT INDEX URL
1 Dry kitten and adult dog food (we ask that the first ingredient listed on the bag be meat). Some Brands we love include: Purina One, Pro-Plan, Wellness, Evolve, Blue Buffalo, and Kirklands 9 http:/​/​pawsshelter.org/​donate/​wishlist/​
2 Cat Litter 10 http:/​/​pawsshelter.org/​donate/​wishlist/​
3 Kongs, Balls, Durable Toys, Puzzle Toys 11 http:/​/​pawsshelter.org/​donate/​wishlist/​
Meta API Result Collection 2 -- it's the entire data set from API #2 and none from API #1
COLLECTION2
ROW LIST.HREF LIST.TEXT INDEX URL API
1 Dry kitten and adult dog food (we ask that the first ingredient listed on the bag be meat). Some Brands we love include: Purina One, Pro-Plan, Wellness, Evolve, Blue Buffalo, and Kirklands 132 http:/​/​pawsshelter.org/​donate/​wishlist/​ PAWS Shelter and Humane Society
2 Cat Litter 133 http:/​/​pawsshelter.org/​donate/​wishlist/​ PAWS Shelter and Humane Society
3 Kongs, Balls, Durable Toys, Puzzle Toys 134 http:/​/​pawsshelter.org/​donate/​wishlist/​ PAWS Shelter and Humane Society
The data structure is verbatim the same. Why don't they combine under meta API?
Testing
A meta API combination worked with 2 APIs, each with one collection.
When there is more than one collection defined, certain combinations of APIS combined partially. Each collection filled with the contents of one or the other API, but never both.
The 3 APIs I need to combine result in one site's results in all of the collections, and nothing from the other two in any collection, and no error logged.
The flaky results seem tied to the collections. But I've moved on to a klugey temp fix, which is to call each API separately and combine the JSON results in my app. 3 API calls instead of one. Might be looking for another tool, soon.
Now it works
Since I posted this question in October, KimonoLabs has updated their app and I am now having consistent success with creating and using a Meta API for the set of single APIs I posted above.
That's the positive.
The catch is that you cannot use the URL parameters in a meta API, so if you'd written post-process modify results functions, they will not be executed, even if you use kimmodify=1.

ESPN API - How can I retrieve college basketball conferences using the Teams API?

The support forums on ESPN.com recommend using Stack Overflow with the ESPN tag. That's why I'm here.
I'm trying to obtain a list of all NCAA college basketball teams using ESPN's Teams API. I started with this GET request:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY
That gave me a list of teams, but many of them are missing. For example, there is no Nebraska. So then I thought that maybe I need to get a list of teams by conference. So I read this in the documentation:
GROUPS: Allows for filtering by "group" or division, e.g. AL East, NFC South, etc. For group IDs and their corresponding values, make a request to http://developer.espn.com/v1/{resource}/leagues. Not applicable to golf and tennis.
So then I try to make a request to `http://developer.espn.com/v1/sports/basketball/mens-college-basketball/leagues?apikey=MY_API_KEY' and it says the page does not exist.
Is this a bug or user error?
First, I think you forgot sports in the resource. Try this:
http://api.espn.com/v1/sports/basketball/mens-college-basketball?apikey=MY_API_KEY&leagues
That will return a mapping of integers to conferences it seems according to the documentation.
That fetched me:
{"name" :"Atlantic Coast Conference","abbreviation" :"acc","groupId" :2,"shortName" :"ACC"}
...and much more.
Then once you have that, let's say 2 = ACC. You should be able to do this:
http://api.espn.com/v1/sports/basketball/mens-college-basketball?groups=2&apikey=MY_API_KEY'
to get everything on ACC mens' basketball teams.
Bear in mind the API is in beta though.
I could not figure out how to get a list of conferences, but I found out how to get the missing teams. When I was making the first get request, it was limiting me to 50 results by default:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY
They have a sandbox where you can play with your parameters, and I saw a limit and offset option:
http://developer.espn.com/io-docs
To get more than 50 results, you have to make multiple requests using the limit and offset parameters.
First Call:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=0&_accept=text%2Fxml&apikey=MY_API_KEY
Next Call:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=50&_accept=text%2Fxml&apikey=MY_API_KEY
And so on...

How to get ids from Freebase given part of a name?

When I go to Freebase.com and search for bush (for example), I get suggestions like George Bush, Kate Bush, George H.W. Bush etc.
How can I get that list as IDs from the query api?
I am trying to get the a list, like this, of ids for a particular name:
[{
"id": null,
"name": "bush",
}]
You can use the search API
https://www.googleapis.com/freebase/v1/search?query=bush
or if you want to use MQL, use can use the contains operator (~=)
https://www.googleapis.com/freebase/v1/mqlread?query=[{%22name~=%22:%20%22bush%22,%20%22id%22:null}]
The contains operator does whole word matching by default. If you want partial word matches, you can add additional wild cards, but you risk running into timeouts, particularly for leading wildcards.
https://www.googleapis.com/freebase/v1/mqlread?query=[{%22name~=%22:%20%22*bush*%22,%20%22id%22:null}]