Dear Team,
Created one sample widget by using the below link, Added in the App Component and later by customizing the form added to the form as well, But unable to view into Task form.
It will be great if you can help me.
Thanks,
Snaush
Ref Link: App component examples
Hi,
I donât understand this part. You coded a form and a widget, what donât you see and where did you expect it?
Hi Bastein,
My requirement to view only widget to the task form to display the details from another ticketing system. I have node.js which is internally will call our Rest API to fetch the record,
Thank you!
Ok your use of the wording âtask formâ was confusing, because AppComponents allow you to create a form as well. You need to go through the docs to create a widget, a task will display a widget if it has the appropriate attachment created on the task. When this attachment is found, your code will be called to render the widget. Does it make sense?
1 Like
I created the widget as per the document. I donât want to open any form pop any to the user.
I just want when any task created in asana, widget automatically render by calling the another app server.
I donât want user to submit any form.
Getting exception when replacing the widget_response with actual value
Code snippet
app.get(â/widgetâ, (req, res) => {
console.log(âWidget happened!â);
var task= âWidgets creation for asanaâ;
var url= xxxx + âxx/tickets?xx=summary="â + task +â"&fields=id,summary,companyâ;
axios.get(url, {
headers: {
Authorization: token
}
})
.then(response => {
tikcteNumber=response.data[0].id;
summary= response.data[0].summary;
company=response.data[0].company.name;
console.log(response.data[0]);
debugger;
var widget_response = {
template: âsummary_with_details_v0â,
metadata: {
fields: [
{
name: âTicketâ,
type: âpillâ,
text: tikcteNumber,
color: ânoneâ,
},
{
name: âSummaryâ,
type: âtext_with_iconâ,
text: summary,
},
{
name: âCompanyâ,
type: âpillâ,
text: company,
color: âhot-pinkâ,
},
],
footer: {
"footer_type": "custom_text",
"icon_url": "https://example-icon.png",
"text": "I'm a footer"
},
num_comments: 2,
subicon_url: "https://placekitten.com/16/16",
subtitle: "I'm a subtitle",
title: "I'm a Widget",
},
};
console.log(widget_response);
console.log(widget_response1);
res.json(widget_response);
})
.catch(error => {
debugger;
console.log(error);
});
});
Can you please let me know what i am missing here!
Thank you!
I might be wrong but I think youâll need some code to upload an attachment on each task.
When you use the example response it does work? And then with your code it doesnât?
No, when the widget gets added correctly, it should automatically create the attachment. I guess itâs possible to hack things by creating the attachment oneself but thatâs not the way itâs âsupposedâ to be done.
But the widget is added how then? As the result of a form being submitted? Because if you canât use a form you have to fake it by uploading your own attachment donât you?
Yes, good point, I think thatâs right. Since @anon6878416 doesnât want to a add a widget via a form, I guess they will have to create the attachment.
1 Like
@Bastien_Siebman @Phil_Seeman any help how to create attachment, also how can i pass the current task name , taskid to widget API .
Thank you!
Yes it is working fine with sample html, not with dynamics actual value from another api response.
When an example works but not my code, I try to modify the example step by step until it matches what I need
Team, Any help appreciated to create attachment via API. Thank you!
Hey @Bastien_Siebman @Phil_Seeman ,
Any help or hack possible to create attachment for display the widgets.
Thank you!
I believe I used the upload attachment endpoint, and passed a resource_name
and resource_url
, the URL matching the pattern given in the app configuration.