Team,
How do I get list of attachment or actual files using Javascript?
for UserTask or tasklistener?
I want to find best way to fetch all the docs and attachments related
to a completed workflow of a given model
Related
I have a SharePoint library with a file in it. I need to get previous versions of the file who created it and when. What is the rest endpoint to fetch those details. I am new to SharePoint. Please help
You could use this rest endpoint to get previous versions of the file by the file id:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions
You could add filters at the end to get the information you need:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions?$select=VersionLabel,Created_x005f_x0020_x005f_By,Created
in order to get additional information from REST API request You need to use the $expand property. If You need information like who made the update please add '?$expand=CreatedBy' at the end of the request.. so for Your example it will be something like:
https:///sites//_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/general')/files('SampleDocFile.docx')/versions?$expand=CreatedBy
that way You will have the user who modified the file in
content>properties>Title
other interesting data is:
updated>
content>properties>CheckInComment>
content>properties>VersionLabel>
All of my workflows for a site have the ability to log data in the Workflow History list on my site. This is controlled at run-time with a parameter in list based on the workflow Name. I would like to be able to run a workflow on this setup table that will delete all records in the History list. My understanding is I can do this via REST call in SharePoint Designer workflow.
I have attempted many times to configure the REST Post command in Designer and I am never able to get this to work. I've searched over and over for a solution and not able to find such a solution.
I first tried deleting all that had the Workflow Association ID equal to the Workflow Name, but could not get that to work. Then I thought I would try selection each value using REST and then deleting that value using REST by the ID I received from the GET.
This is my delete (POST).
[%Workflow Context:Current Site URL%]/_api/lists/GetByTitle('Workflow History')/GetItemObject('[%Variable: HistoryID%]')
I also tried the DeleteListItem
[%Workflow Context:Current Site URL%]/_api/lists/GetByTitle('Workflow History')/DeleteListItem('[%Variable: HistoryID%]')
I want the user to be able to run this on any workflow from the setupWorkflow list I have. The workflow should delete all history for the current workflow.
We can get the list items in Workflow History list base on the WorkflowInstance, in designer workflow, we can get the Instance ID from the Workflow Context.
/_api/web/lists/getbytitle('Workflow%20History')/items?$filter=WorkflowInstance eq 'b87b131e-ce22-43f5-85be-ec81d1045bc7'
Then delete list item using REST API below.
/_api/web/lists/getbytitle('Workflow%20History')/GetItemById(ID)
The following articles for your reference.
Using HTTP Call/ Rest API from SharePoint Designer workflow to create list
workflow to delete list item on subsite( Sharepoint designer call http web service )
Using the Azure API's, I am able to get the content of an attachment using:
GET https://dev.azure.com/fabrikam/_apis/wit/attachments/{id}?api-version=4.1
This assumes you know the guid (id) of the attachment you wish to download.
What I am trying to do is for a given workItem ID, get a list of ALL attachments (including the ID). Anyone know what the easiest way to achieve this is?
I find this Azure API may be helpful for you.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&api-version=4.1
For more details, you can refer to this doc.
Try $expand=Relations in the Api-Url
E.g. GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&$expand=Relations&api-version=4.1
I have been looking to get hold of test results programatically, for the tests that are run during builds and releases. I am doing it via the VSTS API here.
https://www.visualstudio.com/en-us/docs/integrate/api/test/results
The test category information, declared via [TestCategory] attribute, does not appear in this results returned by this API.
I am wondering if there is a way to get hold of test results along with category information?
The test category information is available within the downloaded test results file using the UI from within the test run details.
Is there an API endpoint that return path to the test results file (the one that can be downloaded via the UI)?
Any pointers will be greatly appreciated.
Thanks
To get TestCategory from test file (such as .trx), you use use the REST API to download a test run attachment instead of using the REST API to get test result(s) from a test run.
You can get the test run attachment id firstly, and then download the attachment:
To get the attachment id, use the REST API:
GET https://account.visualstudio.com/DefaultCollection/project/_apis/test/runs/runId/attachments?api-version=3.0-preview
And you can get the attachment id by the id parameter.
To download the attachment, use the REST API:
GET https://account.visualstudio.com/DefaultCollection/project/_apis/test/runs/runId/attachments/attachmentId?api-version=3.0-preview
To get the TestCategory, you can find in the response part:
<TestCategory>
<TestCategoryItem TestCategory="name" />
</TestCategory>
We want to develop a smooth-flowing workflow experience (but still use workflows). Currently, a user needs to use the sidekick to initiate the workflow, then to the inbox, which takes them back to the page to use the sidekick again. When they go to the inbox, they need to restrict to the model and path of the page. It would be nice for the user to only have to go to the content page and from there, launch the different workflow forms that need to happen, like a little "inbox" right on the page that is subject to the workflow.
I have written a custom component that can initiate the custom workflow. The custom component can also query the WorkFlowSession and obtain any active WorkItems for the current page that the component resides (using the WorkItemFilter interface). What I want to do is provide a link to the user to the next step in the workflow from the custom component, just like the inbox does.
Here is an example output from an WorkItem instance toString method:
21.05.2014 09:45:29.300 *ERROR* [0:0:0:0:0:0:0:1%0 [1400679929160] GET /content/test/mailing1.html HTTP/1.1] org.rand.whatcounts.EmailCampaignCoordinator Found workitem: -----------------------------
WorkItem Id: /etc/workflow/instances/2014-05-21/model_1400679794564399000/workItems/node4_etc_workflow_instances_2014-05-21_model_1400679794564399000
Workflow Id: /etc/workflow/instances/2014-05-21/model_1400679794564399000
Payload: /content/test/mailing1
Payload Type: JCR_PATH
key = historyEntryPath value = /etc/workflow/instances/2014-05-21/model_1400679794564399000/history/1400679924113
key = comment value =
My hope is that by using the workflow api items, I can create the link that the user could click on to proceed in the workflow (just like the inbox).
Thanks for listening!
Phillip
There are two ways to implement this
Java-Based Solution
I was able to figure out one way by looking at
http://localhost:4502/libs/cq/workflow/components/inbox/list/json.jsp
The important part of this jsp is that, given a workItem instance, you can get the path for your next step using the JcrPathBuilderManager:
pathBuilder.getPath(wi);
Using this, I was able to output a link to the next step in the workflow to the user (without having user go to their inbox).
Javascript/JSON Based Solution
I didn't go far with this solution (I didn't write any js) but this was my fall back position if I didn't find the java-solution listed above. Once could implement custom JS in CQ Component that would call the json feed for the user inbox, do some client side filtering (to restrict it to only items related to current page). The URL to the feed is
http://localhost:4502/libs/cq/workflow/content/inbox/list.json?start=0&limit=40
Thanks!