What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

create new timeline events through admin api

create new timeline events through admin api

jakehe
Shopify Partner
12 1 7

Hi,

Is it possible to create a new commentEvent in the admin order? I want to add additional details for the order. Like attache a invoice hyperlink or attache a file.

It seems it is not possible for REST API. Is it possible in graphQL? Can you please give me an example.

Thank you

Jake

Replies 10 (10)

HunkyBill
Shopify Partner
4853 60 568

Orders have notes. You can therefore get a reference to the order you want, and attach notes. A link is fine. Attaching a file is not. If you have a file to attach to an order, upload it to some public file storage like AWS S3, and then save a link to that file in the order notes.

You can update order notes with the APIs as long as asked for permission to do so, write_orders. Note that there is really no other way of doctoring up an order like you want.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
jakehe
Shopify Partner
12 1 7

I tried using notes. But how do you add a link? It does not take html tags. In additional to attaching an invoice. I want to record sync logs from my app. Like invoice is created, payment is synced with xero.

There is no way to create timeline comments in order?

jakehe
Shopify Partner
12 1 7

Is there away to add a hyper link to an order? Like <a href="link-to-invoice"> Invoice</a>

Gregarican
Shopify Partner
1033 86 292

Try it 🙂 That was how I gained most of my experience working with Shopify's API. Try adding HTML as a note as see how it looks on the Shopify web UI end. I would usually wind up posting a question here if I spun my wheels for an hour or so and couldn't wrap my head around something. 

jakehe
Shopify Partner
12 1 7

I did. It doesn't work. Maybe I should create a new thread. Thank you

Jayvin
Shopify Partner
284 42 89

Not sure if this is feasible for your use case. But orders do support metafields and thus you can use metafields to store additional details to an order.

banned
Gregarican
Shopify Partner
1033 86 292

What is interesting is that if I manually add an order comment and reference an URL (e.g. - https://www.google.com) then once I save the comment it automatically flags the HTML. Although I found through the REST API the only place I could add things similar to this was through making PUT request to the order and including adding a note in my request body:

 

{
	"order": {
    	"id": 1002221502526,    
    	"note": "Here is a test note."
	}
}

Although the HTML isn't honored if I try something like this:

{
	"order": {
    	"id": 1002221502526,    
    	"note": "Here is another test note, with a <a href=\"https://www.google.com\">link</a>."
	}
}

This is a good question for the Shopify staff to respond to. As if there is a different way to force the API request to instruct of HTML content it would be good to know 🙂 

 

EddieLuong
Shopify Partner
39 1 21

@HunkyBill Could you help to share the reference for the API that create order note? Thanks

HunkyBill
Shopify Partner
4853 60 568

Sure. You can update some facts, but not all, using this endpoint.

https://shopify.dev/api/admin-graphql/2022-01/mutations/orderUpdate

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com