In order to include information (like an order number) in a survey using an Email Collector, it's my understanding that this information needs to be stored in the Contact's custom variables. My concern is what happens if I am sending something like a customer satisfaction survey that needs to reference the order number, and the same customer (email address) places more than one order, and I have to send out more than one survey.
Will the custom values that are returned with the collectors/.../responses API call include the custom values at the time of the survey invite? Or will these be set to current values?
The custom values are stored on the response at the time the survey is taken. So if they change later, they will not change on the response. This will work fine as long as you don't sent out another survey with new custom values to the same contact before they respond to the previous one.
Just an FYI, there is also an option to set extra_fields on a recipient when adding recipients to an email collector (rather than on the contact).
POST /v3/collectors/<collector_id>/messages/<message_id>/recipients
{
"email": "test#example.com",
"extra_fields": {
"field1": "value1",
"field2": "value2"
}
}
I don't believe that data is stored with he response, but the recipient_id is and you can fetch the recipient by ID to get that data back.
Those are two options, you can see which one works best for you. The benefit of contact custom values is that you can view them and edit them from the web, whereas extra_fields are API only fields.
Related
I'm using MS Automate to solve an integration challenge between two systems we use in our Project Management lifecycle. I have a custom connector written by the vendor of System A which allows me to create a Flow in MS Automate which is triggered when a record is Created or Updated.
So far, so good. However, the method in the connector provided by System A returns the new or updated record containing a number of fields which contain value GUIDs as the fields are 'choice' type fields e.g. Department, Status etc. What I end up with is a record where Status = "XXXXXX-000000-00000-00000" etc. The vendor also provides a restful API endpoint which I can query, which returns a JSON collection of fields, which include a 'Choices' section for each field of this type which is a standard JSON which looks like:
{
"Id": "156e6c29-24b3-4413-af91-80a62a04d443",
"Order": 110,
"InternalName": "PrjStatus",
"DisplayName": "Status",
"ColumnType": 5,
"ColumnAggregate": 0,
"Choices": {
"69659014-be4d-eb11-bf94-00155df8457c": "(0) Not Set",
"c30c50e5-51cf-ea11-bfd3-00155de84703": "(1) On Track",
"c40c50e5-51cf-ea11-bfd3-00155de84703": "(2) At Risk",
"c50c50e5-51cf-ea11-bfd3-00155de84703": "(3) Off Track",
"6a659014-be4d-eb11-bf94-00155df8457c": "(4) Not Tracked"
},
Technical problem:
What I have is the GUID of the choice (not the field). I need to take the GUID, in this case "6a659014-be4d-eb11-bf94-00155df8457c" and translate it into "(4) Not Tracked" and store this in a variable to write to a SharePoint list. I need to do this for about 30 fields which are similar in the record.
I've created the flow and the connector has given me the record with a list of fields, some of which contain value GUIDs. I know which fields these are and I have the Display Names of these fields.
I have added a HTTP call to the provided API endpoint (lets call it GetFields), which has returned a 200 response, the body of the response containing a JSON collection of the 50 or so fields in System A.
I can't work out how to parse the body of the response for the GUID I have for each field value and ensure I have the right corresponding text value, so I can then write it to a field variable, and then create a SharePoint record, all wrapped up in an MS Automate flow.
I hope I've understood you correctly but from what I can work out, you want to dynamically select the value of the choice from the GUID you've been provided (by whatever means).
I created a small flow to prove the concept. Firstly, these two steps setup the scenario, the first being the GUID you want to extract the choice value for and the second being the JSON object itself ...
The third step will take the value from the first variable and use it dynamically in an expression to extract that key from the JSON and return the value.
This is the expression ...
variables('JSON')?['Choices'][variables('Choice ID')]
You an see I'm just using the variable in the path expression over the top of the JSON object to extract the key I want.
This is the end result ...
I have designed the User Schema, but I am a bit confused about the User Shipping Address. The user might have many shipping addresses that he wants to save in his profile.
So I am a bit confused whether I should create a separate Address schema and refer the User inside or save the Array of the Address object directly in the User Schema. But, one problem I have noticed; If I save the address in the Address Array under User's Schema, I will not have an object ID for the Address to be identified that which address I want to get. In this situation, I will have to face the problem to update the address.
If someone can tell me how should I go, It will be helpful for me.
You don't need an object ID to do that task.
The solution is that you can just manually assign an id to each address
by just putting both id and address in a json document and then pushing it in the array of addresses.
it will look something like this after in json format
address : [
{
id:1,
address:"address 1"
},
{
id:2,
address:"address 2"
}
]
My project is to import Customers and Sales orders. I take a CSV file from an external program, and am to import them -- field by field -- into Sales Orders and Customers.
My challenge is determining the correct field names to get the REST API to work correctly.
I have the following fields:
I am looking to include the three fields: Description, Gift Message, and Public Comment. I inspect the element, which gives me nothing useful that I can tell. (i.e. none of the values map to the field name that I would use in JSON.)
When I go to the Endpoint for Customers, Description already exists:
And therefore, this JSON Record succeeds in an ADD or UPDATE:
{
"OrderNbr" : {"value": "SO003525"},
"Description" : {"value": "This is the Description"},
}
I extend the default customer (version 18.200.001) and I find and add the "Gift Description" and the "Public Comments" -- and they are listed as part of the "Order Summary" -- which is exactly where Description was.
However, this JSON data does add anything to Gift or Public:
{
"OrderNbr" : {"value": "SO003525"},
"Description" : {"value": "This is the Description"},
"PublicComment" : {"value": "This is the Public Comment"},
"GiftMessage": { "value": "This is the Gift Message"},
}
In talking to the (in-house) developer who set up the screen, he told me that the "Gift Message" and "Public Comments" fields were added on. But they are not showing as "User Defined" fields in the Endpoint.
Questions:
1) How can I know what the JSON structure should look like? Is there some sort of a mapping document, or a printout that shows JSON-to-Endpoint data? What I mean is that sometimes I need to use a sub-object to reference data in JSON, for example, if I want to update "Main Contact" information, I do it like this:
{
"CustomerClass":{"value":"INDIVIDUAL"},
"CustomerID":{"value":"78577"},
"CustomerName":{"value":"TEST CUSTOMER "},
"MainContact":
{
"CompanyName":{"value":"TEST CUSTOMER COMPANY"},
"DisplayName":{"value": "TEST CUSTOMER DISPLAY"},
}
}
How can I know to do that? (I know only because I saw it in the data that got returned when I added a record... Which brings up a second question:
2) Is there a way for retrieving an entire data record in its JSON format. Sort of like a : "GET - SELECT ALL - EXPAND ALL" so I can see all of the data in a record in a properly set up JSON format?
3) Any idea why the gift Message and Public Comments are showing as "Order Summary" but aren't updating like Description is?
4) Why are some things "un-expandable?" For example, I cannot expand Payments in Sales Order. I get an error:
1) How can I know what the JSON structure should look like
The easiest way is to execute a GET request. The field names are equivalent to the DisplayName property stripped of whitespaces. So if on screen the field is labelled Order Type the field name will be OrderType in the request.
To make a GET request, the URL format is /Entity/Keys.
For example entity SalesOrder has two keys: OrderType and OrderNbr.
To get entity SalesOrder of type SO and with the number SO005051 the URL would end with: /SalesOrder/SO/SO005051.
2) Is there a way for retrieving an entire data record in its JSON
format. Sort of like a : "GET - SELECT ALL - EXPAND ALL" so I can see
all of the data in a record in a properly set up JSON format?
If you want all the details, you need to specify them all in the expand clause of the GET query: $expand=Contacts,MainContact,BillingContact
The name of the details array can be looked up in the Web Service Endpoint screen SM207060. They are the tree view elements with a empty array [] suffix.
3) Any idea why the gift Message and Public Comments are showing as
"Order Summary" but aren't updating like Description is?
Those are custom fields. You need to extend the endpoint to add those custom fields otherwise they will be ignored. If there's no issue with the custom endpoint maybe the field aren't bound to database.
But they are not showing as "User Defined" fields in the Endpoint.
If by User Defined you mean those fields were added with a wizard (without programming) then this is likely the reason why they don't work in the web service. You would need to add custom field with a DAC extension which requires programming instead of the User Defined field.
I'm struggling to work out the correct REST endpoints for a certain situation. On my website it's possible for users to send messages to each other. One user is able to send messages to multiple recipients.
I think that /v1/users/123/messages would return all messages that have been sent to user 123
What end point should I use for messages that user 123 has sent?
My database structure is as follows...
accounts table
id INT
username VARCHAR(64)
messages table
id INT
account_id INT <!-- This is the senders account ID
subject VARCHAR(128)
message TEXT
messagerecipients table
id INT
message_id INT
account_id INT <!-- This is the recipients account ID
The messages table defines a one-to-one relationship between a message and its sender
The messagerecipients table defines a many-to-many relationship between messages and their recipients
Also I'm reading through a PDF on API design at the moment which seems to suggest I should hide this kind of complexity behind the query string.
For instance....
/v1/emails?filter=author_id(123)
/v1/emails?filter=recipient_id(123)
Thoughts?
I would expect
/v1/users/123/messages
to return all the messages that belongs to this user. This means received, sent, deleted, tagged, drafted etc.
To specify a subset of a resource you can go two ways with this like you and bertvh stated:
Querystring:
I find it perfectly valid for filtering as e.g.
/v1/users/123/messages?type=received&folder=important
Or as a subresource:
Use this if you expect to have a lot of filter options on a higher level e.g.
/v1/users/123/messages/received?folder=important
As you can see this would reduce a filter option.
And like bertvh stated, the underlying database schema is irrelevant for serving the responses.
I would do something like this.
To get all messages sent by a user:
/v1/users/123/sent
To get all messages received by a user:
/v1/users/123/inbox
Your database structure is irrelevant for the resource scheme but it can influence the payload structure. If you want to use JSON a message could look something like this:
{
sender: 123,
receivers: [124, 125]
content: "My message content"
}
I know I can pass a field name "CUSTOM" which is supposed to come back in IPN can I pass two values as for example CUSTOM0 and CUSTOM1? or something like that
You can't pass multiple fields, but you could pass multiple values in that 1 field if you need to. For example, you might include a value like...
val1|val2|val3|val4
Then in your IPN script, you could handle it like the following PHP sample...
$custom_values = explode('|',$_POST['custom']);
Then your custom values would all be available in the $custom_values array for you to use accordingly.
You could also send an NVP string or an XML string if that help you keep things straight, but keep in mind the CUSTOM parameter only accepts 256 characters.
If you need more than that, or if you just prefer, you could always save the data in a local database and then just pass a record ID in the CUSTOM field so that you can pull all those details back out of your database within your IPN script using that record ID.