Is there a way to assign the primary category for a product in demandware using the Open Commerce API (OCAPI)? - demandware

The primary category of a product is present in the product document (primary_category_id) in the DATA API but cannot be written. After sending a PATCH update of the product with a different primary_category_id, it doesn't change.
Is there a way of doing this through the OCAPI?

Can be some limitation for PATCH Method.Fields that can be updated:
name,
page_description,
long_descripton,
page_title,
page_keywords,
brand,
ean,
upc,
manufacture_sku,
manufacture_name,
searchable,
unit,
searchable,
online_flag,
default_variant_id.
Try with PUT Method. PUT https://hostname:port/dw/data/v19_1/products/{id}. Also,
please check Request Document.

At this time it does not appear that this is possible to manage via OCAPI.
I suspect that in the future you'd be able to achieve it using the following resources:
DELETE /catalogs/{catalog_id}/categories/{category_id}/products/{product_id}
followed by:
PUT /catalogs/{catalog_id}/categories/{category_id}/products/{product_id}
With a ProductCategoryAssignment document in the PUT call.
However, this would require that Salesforce adds those attributes to the ProductCategoryAssignment document.
The reason I suggest this is where it would be added is that within a catalog import document (XML) the flags are associated with a similar resource representation. eg:
<category-assignment category-id="gear-bags-backpacks" product-id="NSF4003100">
<primary-flag>true</primary-flag>
</category-assignment>

Related

qbo3 Document Review Workflow

I have a series of documents in a document imaging system that need to be manually reviewed.
I can query the relevant documents from my data warehouse via an API call (Process/DataWarehouseDoucmentQuery), which will return data along these lines:
Account
Document
Status
IndexId
12345
Document A
Late
9876
12345
Document B
Late
5432
12345
Document C
Late
1098
23456
Document A
Late
7654
23456
Document D
Late
3210
The goal is to:
Create a Task for each document
Create a Workflow for each document
Group the documents associated with the same account under common Process
Configuration should include:
Create a Workflow Template, perhaps named Document Review, that applies to Attachment
Add a Task to this workflow, perhaps named Document Review
You can use qbo's ImportFile/BatchApply feature to create a scheduled job along these lines:
Query: Process/DataWarehouseDoucmentQuery
Action:
Attachment/Save?
Attachment={Document}
&SubscriberID={IndexId}
&Status={Status}
&Decisions_DocumentReview_Decision={Document} Review
&Process={Account}
More detail on the parameters you are passing:
Parameter
Description
Attachment
This is the same as the name of your document; adjust as you see fit.
SubscriberID
This uses qbo's Subscription pattern to ensure you don't create duplicate documents. This assumes that your IndexId is effectively globally unique in your environment.
Status
Since it's part of your data warehouse query, might as well map it to Attachment.Status.
Decisions_DocumentReview_Decision
Any qbo object can save related table data by specifying {Child}_{Template}_*. Note that when passing Template, you should remove any non-alpha-numeric characters from the template name.
Process
The Attachment module is based on qbo's GenericObject, which can be a 'child' of any other object. In this case, the Attachment will be bound to a parent Process, which will be created on the fly if required.
Note that creating a parent Process record as detailed above required that the application setting for GenericParentClasses include Process. This can be verified from the Configuration > Modules > Matrix > Settings panel.
An alternative to adding Process to GenericParentClasses is to specify both an Object to indicate the parent, and {Object}_* to indicate parent field values:
Attachment/Save?
Attachment={Document}
&SubscriberID={IndexId}
&Status={Status}
&Decisions_DocumentReview_Decision={Document} Review
&Object=Process
&Process_Process={Account}
&Process_OpenedReason=Just a Stack Overflow Example

Updating Stripe metadata example

Is it possible to update subscription' metadata after it was created ?
For example change some Ids or other related information
You can certainly update metadata on a Subscription object. Simply retrieve the Subscription and add or edit any metadata properties. Things such as the subscription's id, however, are immutable and not something a user can define.
sub = stripe.Subscription.retrieve("sub_xxxxxyyyyzzzz")
sub.metadata['order_id'] = "A1234"
sub.save()
https://stripe.com/docs/api/subscriptions/update?lang=python#update_subscription-metadata

Clio API - What is the correct format to Update (PATCH) a custom field value for a matter

Anyone been able to successfully update the custom_field_values for a matter via Clio's API?
I'm trying to update the value for custom_field_values under a single matter. I'm able to send a JSON string using PATCH and update the default values for a matter like location or description using the following format
{"data":{"location":"Orange"}}
But when it comes to updating a "custom field value" I'm getting a 422 Unprocessable Entity error. I'm following Clio's v4 API Documentation and my understanding is that to update a custom_field_value you need the following JSON:
{"data":{"custom_field_values":[{"id":658213,"custom_field":{"id":139385},"value":"New Value Goes Here!"}]}}
However here is the message coming with the 422 error:
{"error":{"type":"ArgumentError","message":"An invalid argument was supplied: invalid custom field value id provided, acceptable format is <type>-<unique id>"}}
I can't interpret the part suggesting the acceptable format!
I've also tried sending the JSON in the following format which is closest to Clio's V2 API Docs for updating a custom field:
{"data":{"custom_field_values":[{"custom_field":{"id":139385},"value":"New value goes here"}]}}
But then this is what I get back:
{"error":{"type":"ArgumentError","message":"An invalid argument was supplied: custom field value for custom field 139385 already exists"}}
Please note that this is being tested in POSTMAN regardless of my development environment. I appreciate your response!
I've successfully created queries to update custom field values in matters many times, and these run all the time for me. I've compared your json to some examples of the json I'm successfully sending. Your syntax appears correct, but there's enough missing for me to only guess at where your mistake might be.
First, you're sending a PATCH to https://app.clio.com/api/v4/matters/{matter id}.json right? It took me a while to learn that you can't update the value of a matter's custom field with a query to https://app.clio.com/api/v4/custom_fields/{id}.json.
Second, just to clarify, the 658213 id you used above (the first id field) should be the unique id of this instance of your custom field. You won't get this until you've created an instance of the custom field particular to this matter. The second id field, where you've put 139385 is the id for the custom field itself, which you could get with a query to https://app.clio.com/api/v4/custom_fields.json.
If you're looking in the V.4 docs under Custom Fields, you won't find this, or at least I didn't. BUT you can find it in the intro section to the Matters portion fo the documentation: https://app.clio.com/api/v4/documentation#tag/Matters
Hope this helps. I'd imagine someone at Clio could help by verifying your error string is delivered when you have an incorrect custom field value unique id.
To further clarify Jacob's answer for everyone else:
custom_field{id} is the id given to a custom_field when it's created and will be the same for all matters or contacts it's used in.
custom_field_value{id} is the id given to an instance of the custom_field added to a particular matter and unique only to that matter
To add a custom_field to a matter for the first time the following format is used:
{"data":{"custom_field_values":[{"custom_field":{"id":123456},"value":"string or integer depending on the type of CF"}]}}
To update a custom field already added to a matter the following format should be used:
{"data":{"custom_field_values":[{"id":"text_line-1234567", "custom_field":{"id":123456},"value":"string or integer depending on the type of CF"}]}}
To delete a custom field already added to a matter the following JSON format is sufficient:
{"data":{"custom_field_values":[{"id":"text_line-1234567", "custom_field":{"id":123456},"_destroy":true}]}}
Format for updating a custom field already added to a matter:
{"data":{"custom_field_values":[{"id":"unique_instance_of_your_custom_field", "custom_field":{"id":'custom_field_id'},"value":"value which should be updated"}]}}
Here, the first id field should be the unique id of this instance of your custom field. To get this value follow this documentation section, app.clio.com/api/v4/documentation#tag/Matters and the second id field is the id for the custom field itself.

How to return only selected items from Pods Framework?

Just started using the PODS framework for Wordpress. Most of it I picked up pretty fast, the rest I'm struggling with. Below is an example of my confusion:
I created a custom post (Partner Bio) with auto-templates turned on.
I created a pods-template (Bio for Industry) that is sourcing post (Partner Bio).
I created another custom post (Industry) with multi-select post-type relationship field to post (Partner Bio).
The issue I'm having is that when I create an instance of post (Industry), then select specific items from that relationship (Partner Bio), (say there are 10, but I chose 3), I'm getting data returned for all of Partner Bio's instead of just the three I chose, so in other words the template pulling data from all Partner Bios regardless of what I choose in the post field drop down.
The template I'm using looks like this:
<div>{#post_thumbnail.thumbnail}<br/>
{#first_name} {#middle_initial} {#last_name}<br/>
{#title_of_partner}<br/>
{#position}<br/>
{#phone}<br/>
Email {#first_name}
</div>
This made me think that when you embed a pod usinge a shortcode, it's not being controlled by the fields selected when you edit your post. So then I tried grabbign the code from the template and then just dropping it in the post, that did not work either.
My goal is to display the block listed above one under another, based on which bios I choose. What am I doing wrong?
If my example above is confusing, here's a simpler sample illustrating the same issue, this maybe more clear:
Post A structure/fields:
Name,
Email,
Rel, // Post A's Relationship via post-type to Post B,
Auto templates: on,
Pods Template created: {#name}{#Emal}{#Image}
The issue, is when I create an instance of Post A and select items from the Rel, I'm getting values pulled in from all members of that relationship rather than just what I checked off.
If I turn off auto templates and drop in magic tags into the instance of Post A, I do get back only data for the relationship items I chose but I ge it back in this format:
Name and Name and Name
Emaile and Email and Email
Rather than:
Name
Email
Name
Email
...

ItemInventoryQuery is not returning all the available fields.

We are using Web Connector on the end where QBPOS 10.0 is installed.
On the server end we issue an ItemInventoryQuery request using QBPOSFC3.0 (QB POS Foundation Classes).
The response we receive from Quickbooks contains most of the fields available on an inventory item, but there are some fields that are not being returned, specifically, "Unit of Measure" is not being returned on the XML we receive from Quickbooks.
Per the on screen reference, the "UnitOfMeasure" is a field available on the response of an ItemInventoryQuery
https://member.developer.intuit.com/qbsdk-current/Common/newOSR/index.html
Nonetheless I am unable to obtain these values, the "UnitOfMeasure" nodes do not even exist on the XML response we get from Quickbooks, everything else is good in the response (e.g. item ListID, name, vendor, etc.)
What am I missing here ?
Here is a sample of the XML response we receive:
http://pastebin.com/pA6KDr0k
I just checked some of my old source code and found that I was explicitly telling it which fields to return. For example:
query.IncludeRetElementList.Add("UnitOfMeasure1");
query.IncludeRetElementList.Add("UnitOfMeasure2");
query.IncludeRetElementList.Add("UnitOfMeasure3");
I don't remember if I did this because of the same problem you're having, but I do know I got the UOM fields in the response. Hope this helps!
Check unit of measure is enabled for the company file in preferences -> items & inventory -> Company preferences tab. It is disabled by default in new companies.
You are missing other fields too such as time created.
If you included any IncludeRetElementList lines in your request that will limit your results.
So You will have to add IncludeRetElements for UOM as Mike suggested.
If that doesn't work I'd suggest posting your request.