How to find Trello ListId's or CardId's with Trello.NET - trello.net

I'm trying to find all cards in a specific list using Trello.NET
In the examples given it's clear to to find all list names in a Board, and all Cards in a Board. However if I want to find all Cards in a specific List, as far as I can see I need ListID (can't filter by List Name) by using trello.Lists.WithId()
Knowing the List name, how can I determine what it's ListId is so I can subsequently filter for all Cards in it?
And if I would subsequently like to edit an existing Card, how can I determine the CardId.

Use LINQ and filter in-memory:
// More than one list can have the exact same name, this finds the first:
var list = trello.Lists
.ForBoard(board)
.FirstOrDefault(list => list.Name == "name of the list");
if (list != null)
{
var cards = trello.Cards.ForList(list);
// ...
}
You could use a similar technique to find a card if you know it's name: use trello.Cards.ForBoard or trello.Cards.ForList first, and then filter by name afterwards.
For cards there is another option though: trello.Cards.Search. For example:
var cards = trello.Cards.Search("name of the card");
The search will be performed on the server in this case.

Related

Triggering Zapier on new Shopify order containing a specific product

I have a simple Zap that is triggered on a Shopify New Order (with line details) and then creates a new account in a system called Trainerize. Works perfectly, but it is triggered by ANY new Shopify order. I need to trigger the Zap for a specific product in the Shopify order. Is this possible in Zapier, and how would I go about it? It seems you can't talk to Zapier support unless you have a plan, and I don't want a plan if it is not possible!
Yes, it is possible. The exact implementation depends on how you want to identify the specific product. I am listing 2 possible ways
In case, the criteria to identify product is quite simple, you can use Filter by Zap. For example, if you want to identify product by product Id, you can just add a Filter by Zap and add the following conditions.
Line Items Product ID | Text Contains | Your Product ID - 12345
If you have some complex matching condition for your Product, you can also use Code by Zapier to run JavaScript code. To do so, pass the required data as input to code and return output that can be used later to see if the match was found. A simple example that gets LineItems productIds as input.
const TARGET_PRODUCT_ID = 12345;
const productIds = inputData.productIds.split(",");
output = {targetProductFound: false};
productIds.forEach(id => {
// Add more conditions if needed
if(Number(id) === TARGET_PRODUCT_ID){
output.targetProductFound = true;
}
});
return output
Then use Filter to proceed or abort.

Filtering Content in Sanity Studio

I am wondering if it is possible to filter content in Sanity Studio according to set criteria. For example, return all published posts or all posts within a particular category, etc.
Here is a short video showing what I mean: https://www.loom.com/share/5af3a9dd79f045458de00e8f5365cf00
Is this possible? If so, is there any documentation on how to do it?
Thanks.
The easiest way I've found to make all kinds of filters is using the Structure Builder. With it you add as many sections you like, name them, and give it your own filter in the form of groq and params.
Se documentation: https://www.sanity.io/docs/structure-builder-introduction
As an example I've added a S.listItem to the deskStructure.js file that gets all articles that are missing the module field.
export default async () =>
S.list()
.title('Content')
.items([
// ...
S.listItem() // <-- New root item for my filters
.title('My article filters')
.icon(FaRegCopyright)
.child(
S.list() // <-- List of filters
.title('My article filters')
.items([
S.listItem() // <-- Item with filter description
.title('Articles without module')
.icon(FaCogs)
.child(
S.documentList() // <-- Filtered list of articles
.title('Articles without module')
.menuItems(S.documentTypeList(menuType).getMenuItems())
.filter('_type == $type && !defined(module)')
.params({ type: 'article' })
),
S.listItem(), // more filters
S.listItem(), // more filters
])
),
// ...
It doesn't make different filters on one list of elements. It's more making different lists that are all ready filtered as you need. And you can give it what ever icon and text you want. Potato/potàto ,'-)
In the sorting list I don't think you can do much other than adding more sorting. And It doesn't work when the list of elements get larger anyways so I wouldn't bother. But it's in the Sort Order section: https://www.sanity.io/docs/sort-orders

How to get user from User field LookupId

I have a list in sharepoint online.
And in this list, i have a person field.
When i call the API endpoint to get all the items in the list, i get an LookupId value for the person field.
I tried to get the user by using the value of the lookupid, but it don't work because the id is not recognized.
The lookupid is a int (eg: 21) instead of a guid.
Is there something missing in the configuration of the person field or in my calls to Microsoft Graph API ?
When a user signs into a SharePoint site collection for the first time, a ListItem is created in a hidden User Information List. The LookupId in a PersonOrGroup field refers to the ListItem in this list. The URL for the User Information List for SharePoint Online should be:
https://{yourTenant}.sharepoint.com/{yourSiteCollection}/_catalogs/users/detail.aspx
Since the User Information List is a generic SharePoint list, you can query the list via Graph. First, get the list id for the User Information List. An easy way to get the list id is to view the source for the User Information Site via Chrome and search for 'listId'. You should find a result like this:
"listId":"{yourListIdIsHere}"
Copy the id. By using the copied id, the id of your root site and the LookupId, you can get the ListItem in the User Information List:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{pasteCopiedListId}/items/{lookUpId}?$expand=Fields
The ListItem contains information about the user, such as the email, which can be used to identify the Azure user:
https://graph.microsoft.com/v1.0/users/{eMail}
Question: How could i get the hidden User Information List from Microsoft Graph?
If you do not want to use the 'trick' with Google Chrome to get the id, there is another way to get the site. Typically, if you want to get the id for any site, you would call:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists
However, you will not find the id of the User Information List, even if you include hidden sites. I do not know why. An additional problem seems to be, that you cannot filter lists by their name:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=name eq 'users'
The query returns an error, that the provided filter statement is not supported. The only way to get the list without knowing the id seems to by using the property displayName of the list. However, the displayName is based on your localization. So, since I am from Germany, I can get the site by using the query:
https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=displayName eq 'Benutzerinformationsliste'
You will need to replace Benutzerinformationsliste with your localized name. For EN replace it with 'User Information List'.
This returns the expected result:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('xxx')/lists(id,name,displayName)",
"value": [
{
"#odata.etag": "\"xxx\"",
"id": "xxx",
"name": "users",
"displayName": "Benutzerinformationsliste"
}
]
}
As you can see, the name of the list is 'users', so why the first filter statement does not work is a little mystery to me. Maybe someone here knows and can help out.
Some of the queries above don't work at the moment.
What I finally found as a good solution - after trying many many queries - is that you can do this by following the few steps below:
1- Get the GUID of the user information list.
Using the title of the list "User Information List" or the name "users" in the parameter "$filter" does not work.
Don't forget 'system' among the properties you select if you want to retrieve the hidden system-lists.
GET https://graph.microsoft.com/v1.0/sites('{site_id}')/lists?select=id,name,system
2- Filter the previous result in order to pick up the ID of the targeted list named 'users'.
By the way, applying this restriction "$filter=name eq 'users'" does not work.
You will get an exception. So you must do the filtering part by writing a few lines of code.
3- Once you've got the list identifier, then select all the items you want. And voilà! The word 'Fields' must be in pascal case (uppercase the first letter ).
GET https://graph.microsoft.com/v1.0/sites('{site_id}')/lists('users_list_id')/items?$select=Fields&$expand=Fields
As #QuestionsPS1991 mentioned, the people field in fact refers to the hidden user list. With the lookupid, we can get the user via below methods:
Get user by id
Get user property by expanding lookup field
//////////// updated
By default, MS Graph does not return this user list. You may hard code the list id or follow ##QuestionsPS1991 suggestion. Below is my test:

Transaction BODY Field from COLUMN Field (Netsuite)

I have an issue where some of our orders are being imported directly into Netsuite, and there is information from the first line item, that I need to copy into the transaction record (i.e. custom field on sales order)
I want to set this up so that it is automatic, I don't have access to the system that is used to bring the orders into Netsuite, and I only JUST got suitescript access and everything I read about that is way above my head..
I know basic HTML and some of the scripting formulas from Netsuite and that's all.
I was hoping there would be a CUSTOM FIELD FORMULA or some other similar way that I can just easily source the information directly from the first item in the item sublist?
This would be quite trivial to implement using SuiteScript. The example below assumes you want to copy the Memo field (description) from the first line item to the body Memo field. The basic idea would be something like the below (untested code):
function userEventBeforeSubmit(type){
if (type === 'create') {
var record = nlapiGetNewRecord();
var memo = record.getLineItemValue('item', 'memo', 1);
record.setFieldValue('memo', memo);
}
}
If want to accomplish this via custom fields etc. it is possible using "Custom Fields with Values Derived from Summary Search Results".
To do this create a Saved Search as follows:
Type: Transaction
Criteria: [none]
Results: Formula (Text), Summary
Type = Maximum, Formula: DECODE({line}, 1, {memo}, NULL)
Available Filters: Internal ID
Then create a Custom Transaction Body Field as follows:
Type: Free Form Text
Store Value: F
Validation & Filtering > Search: [Saved Search from previous step]
As this is a dynamically calculated field (Store Value = F), it would be available when viewing the record, but not in Saved Searches and lists. To remove this limitation, you can create a Workflow that would copy this field to another one that is stored.

permanently sorting a collection

I have an observable collection that is exposed to the user by a collectionviewsource. One of the properties on the items in the collection is sortorder. I am trying to allow the user to permanently resort this collection and propagate the changes to the db.
I have the CVS working where I can resort the individual items as they are displayed in the listbox. Now however I have to change the item.sortorder==cvs.currentindex and i am having trouble figuring out the proper way to do this.
EDIT
evidently I was not clear enough. Sortorder is a field in my DB that is part of my object that allows the user to control position of the items as displayed in list controls. I am trying to give my user the ability to change how these items are sorted in the future by changing the value of the sortorder field to equal the current index of the displayed item.
items current sortorder value is 3.
user moves displayed listitem to position 0(ie first position)
items new sortorder=0 item with original sortorder will become 1 etc
this would be achieved by looping through the sorted CVS and making Item.SortOrder= CVS.Item.index
Databases return rows from table based typically on the order they were added to the table unless you specify an order by clause in your query. changing the order in the database is not a good idea. instead, try something such as using a parameterized query and passing in the column and direction you wish to be sorted which is retrieved from a user preference.
I figured it out.
I went back and looked at the code that I was using to change the position of the elements and I am actually using the collection itself:
private void OnDecreaseSortOrderCommandExecute()
{
int index = QuestionsCVS.View.CurrentPosition;
QuestionsViewModel item = SelectedQuestionVM;
if (item != null && index > 0)
{
SortableQuestionsVMCollection.RemoveAt(index);
SortableQuestionsVMCollection.Insert(index - 1, item);
QuestionsCVS.View.Refresh();
QuestionsCVS.View.MoveCurrentTo(item);
}
}
So I simply did this:
private void ResortSortableQuestionsVMCollection()
{
for (int i = 0; i < SortableQuestionsVMCollection.Count; i++)
{
SortableQuestionsVMCollection[i].SortOrder = i;
}
}
I dont know if this will work in every circumstance but it certainly did what I wanted for this one.