YouTrack JavaScript Workflow - send email to global group - youtrack

I am creating a state machine for YouTrack using JavaScript, and am trying to send an email to everyone in a group. In the old Workflows, this was done like this:
{group:PHP Developers}.notifyAllUsers("Subject","message");
I can't find anything in the new JavaScript API to do this, where can I find the global (not issue or project) groups?

In JS API it will look as follows:
entities.UserGroup.findByName('PHP Developers')
.notifyAllUsers('Subject','message');
However, another (and way more reliable) way to get a particular user group is to add it to requirements and the reference inside the code:
ctx.phpdevs.notifyAllUsers('Subject','message');
...
requirements: {
...
phpDevs: {
type: entities.UserGroup,
name: 'PHP Developers'
}
}
You may find more details in official documentation: UserGroup and Finding Specific Entities.

Related

Accessing site options via a REST API

I'm building a REST API powered SPA application and I'm trying to decide on the best way to deliver "global options" via the API. By global options I mean an assortment of random fields that relate to the application as a whole rather than being associated with one specific model, for example brand logos and contact details that need to be accessible from multiple locations within the app.
Something like Wordpress would store these in an options table and access them via a php function using the option name, however since this is a REST API I'm not sure how I would go about accessing/updating multiple options without making lots of requests for each one.
I know a lot of projects just use a json file to store this data, but it specifcally needs to be editable via a CMS and served via the API. The following are two methods that have come to mind, but none of them feel like complete solutions:
1: An options table with one generic endpoint that takes a query string specifying which fields you want to access. This works for getting data, however updating data seems to get a bit messy and the only way I can think to do this is by sending an object of key/values pairs to bulk create or update the options:
GET: example.com/api/options?pick=logo,contact_phone,contact_email
POST: example.com/api/options
{
contact_email: "info#example.com",
contact_address: "123 Test St"
}
PUT: example.com/api/options
{
contact_email: "info#example.com",
contact_address: "123 Test St"
}
2: Breaking fields into groups and storing them as a json field in a "pages" table, this solves the creating and updating issues but breaks down when you have fields are used in multiple locations, and they aren't really pages so it's not very REST like.
GET: example.com/api/pages/contact
POST: example.com/api/pages
{
name: "contact",
values: {
email: "info#example.com",
address: "123 Test St",
}
}
PUT: example.com/api/pages/contact
{
values: {
email: "info#example.com",
address: "123 Test St",
}
}
I also need to take into account the issue of access permissions, for example the logo field would be accessible to the public, but the user support contact number would only be accessible to logged in users. With the first example you could have an extra permission column for each option, but this wouldn't work for the second option.
I've been googling but have failed to find any good information about this topic as REST schemas/documention generally only deal with concreate entities, so any insight into how this is achieved in real world applciations would be great!
Cheers,
Cam

TODOIST API: How to get list of users to assign a specific user to task?

It seems that API allows to assign users to a task (called an Item in the API) using the body field responsible_uid at the add an item endpoint. However I cannot find a way to list user uids or any other way to get user details anywhere in API documentation.
Official python library todoist-python doesn't provide any way to do this either. So for now it seems I can only create tasks without assigning them to anybody, which is a bummer.
Any advise grately appreciated!
Links:
Todoist Sync API
Todoist
REST API
You should first share a project and then you can get all collaborators in the Sync request.

how to create a list template in SharePoint online using VS 2013

I am going to create some declarative items in SPO using VS. I know how to create it through UI by I want to create programmatically. As I did some research, there are 3 ways.
First is through SP hosted App(add-in) then give manage permission on host web to create some list on its parent site.
Here is the article:http://www.sharepointnadeem.com/2013/12/sharepoint-2013-apps-access-data-in.html
This approach is not good because App web shouldn't apply any change on its host web.
Second is through Sandbox solution. Once I try to create a sandbox solution using SPO site URL, I will receive an error which said connecting to a remote site is not possible through VS. So I have to enter a local SP URL to create a sandbox solution. then I should create list template declaratively and deploy it and publish it to my SPO environment. Here is the article which explain steps:http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/01/10/how-to-use-visual-studio-11-to-publish-solutions-to-sharepoint-online.aspx
The problem that I have with this approach is I don't have access to my managed metadata columns which are located in SPO once I am developing list template in my local development machine.
Third approach is creating List or content type or template in App web which is not my case. This has been explained in this article:
sharepoint-journey.com/sharepoint-list-in-sharepoint-hosted-app.html
The problem here is, I want to have that template in my site (host site) not in App web site (sub site)
My question is: I want to provide some list template in my SPO environment by using VS 2013. what is the best approach for doing that? and how can I do that? Please give me an step by step instruction.
Thank you
You definetly want to go the App(Add-in) way. It is possible and in many cases prefereble to set up your lists on the host web and then just use the app web for a user interface, or if you don't want to utilize it at all: Just let the add-in do the heavy lifting in creating lists, columns and content types.
The important thing here is that you specify in your code that you want the lists to be created on the Host Web and not the App Web. For this to work you need to include a permission request in your app. When installed, the app will ask the user installing it if it can have permission to the host web. This is done by setting the relevant scope in your AppManifest.xml file, and then you set it under Permission: [your scope] - [permission level] You can read more about this at this resource: https://msdn.microsoft.com/en-us/library/office/fp142383.aspx
Then something like this code will allow you to create a list on your hostweb. Keep in mind that this list will still be available on the host web even if you remove your app.
oApp.install.addList = function (listName) {
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title(listName);
listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
var myNewList = hostcontext.get_web().get_lists().add(listCreationInfo);
var dfd = $.Deferred();
context.load(myNewList);
context.executeQueryAsync(function () {
var listCreated = true;
console.log("[" + listName + "]" + " added to hostweb");
if (listCreated) dfd.resolve();
}, oApp.onFail
);
return dfd.promise();
};
I also wrote about creating certain types of columns on your list at my blog. Feel free to check that out here: http://bayerlein.se/how-to-create-host-web-lists-with-certain-columns-in-your-sharepoint-add-in-the-nice-way/

Adding recipient Groups to a CiviCRM Mailing via REST.. how?

I have been able so far to create a new civi Mailing object and populate it, but confusingly I can't see a parameter in that to specify the mail destination group.
For context, I am dealing with Civi using pure REST api from a remote server. I have a solution to getting a custom template onto the server; the new problem is setting a schedule and delivery group, and initiating the send. I am using the python-civicrm library from github as the intermediary on the client.
I presume send happens as a result of setting the schedule -- i.e. I don't need an API call to say 'send mailing'? Is setting 'sheduled date' == 'now' safe or should I set a date of 'now + 1min' or similar?
So that leaves setting the delivery group. We already have groups defined in the DB, and I want to specify the group by name (and preferably be able to verify in advance that a group name is a valid destination, perhaps by doing a group name -> id lookup).
I think there might be a parameter to Mailing create 'groups' which can have keys 'include' and 'exclude'; at least, that's what the web form seems to do. However it's not mentioned in the REST api implementation.
Can anyone offer pointers?
I think you will find all you need in the following link :
Example of api call that is using the group include/exclude : https://gist.github.com/xurizaemon/6775471
Discussion about implementing mailing as an api - http://forum.civicrm.org/index.php?topic=24075.0
Otherwise, if it doesn't work, i suggest that you :
help adding this api in the CiviCRM Core - you could have some help on this on irc #civicrm (and have a look at https://issues.civicrm.org/jira/browse/CRM-11023)
OR create an extension with the api you need. It will be automatically available for REST. If you haven't created an extension yet, i suggest you go to the page http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension. It's quite straightforward with civix installed.
The table you need to check in the database is civicrm_mailing_group
To confirm, the problem was that (a) I needed to use groups[include]=array(ids) as mentioned by samuelsov, but also (b) I needed to use the json={...} form of request through REST, because the HTTP params syntax doesn't support nested data.

AtTask create/update a custom field through API on project creation created through AtTask's web app

I'm looking to use AtTask's API to update or create a custom field (ie. assign a custom ID apart from AtTask's auto-generated id) whenever a project is created through the web app. But I have not found anything about handling events in the API documentation.
I'm able to retrieve/edit project fields when issuing a request by ID or some other search parameter.
But I'm having trouble finding ways to edit project fields on some event like 'project created'.
One way I can think of is to have my script periodically search for new projects based on project metadata and edit projects that way, but there must be a better solution I probably missed.
Thanks in advance!
UPDATE:
It seems 'AtTask event subscriptions' was what I was looking for. At the time of the post below (12/2013), due to scalability issues, AtTask has turned this feature turned off with no ETA on resolving the issue. See here: Does AtTask event subscription work?
Any updates would be appreciated.
You are correct the AtTask API does not currently support events. The easiest thing to do is to just poll the system for updates using the search. You could also monitor an email address for emails that are sent upon project creation. The email will contain the project/task/issue ID that you can use to update events.