In Debezium add to the ExtractNewRecordState a specific field from the "before" record - debezium

I want to extract only the new record from a record update/create, so I am using:
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
But I would like also to add a status field from the old record. I, of course, don't want to add the whole unnecessary before record.
Trying to do:
"transforms.unwrap.add.fields": "before.status",
doesn't work, since I am getting
java.lang.IllegalArgumentException: Unexpected field name:
before.status
Is there a way to add a specific field to the message model?

Related

How to search on a field that may be empty in zapier

Trying to sync up a postgres record to airtable on create/update. The field has a couple of ids that I would like to check for in airtable to determine whether I should create a new record or update an existing one. The first id (optional_id) I need to search on can possibly be null. This causes the search to fail before it can get to the other id(required_id) that should always be populated. Is there any way I can skip the initial search for optional_id if it turns out to be null in postgres?
My current outline is as follows:
I would use a Formatter > Text > Default Value step in case the input value can be null and then make sure the fallback value is from a record that does not exist.
If further help is needed, feel free to reach out to us here:
https://zapier.com/app/get-help

trigger on opportunity whenever the data of the field get changed in the Custommetadata, then update that field data on the related Account field

2 Fields on Custom metaData:
Opportunity Field Name
Account Field Name
trigger on opportunity whenever the data of the field get changed (the field that are mentioned in the Custom metadata), then update that field data on the corresponding Account field.
I tried to get Field Values from Custom metaData like Map<Id,Object_Field_Mapping__mdt> metaData = new Map<Id,Object_Field_Mapping__mdt>([SELECT Account_Field_Name__c,Opportunity_Field_Name__c FROM Object_Field_Mapping__mdt]);
And now the problem is I am not able to compare these value with the whole Account object so that i can update on Opportunity.....This sounds little bit confusing but this is what i have to do
Is there any way to compare CustomMetaData Field Value with Account Object..
Someone told me it can be used by Schema/sObjects but I am not sure how
You can use Schema like this
Map<String, Schema.SObjectField> accFields = Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap();
and you can access its field value like this accFields.values()
for(Schema.SObjectField field : accFields.values())
{
//Some Code here
}
for more information about Schema Class and it's Method please check Schema Class
Hope it Helps
Thanks

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.

PUT multiple related records in Data API request

In the documentation from FMI the HTTP-body example for creating records using FMS16 Data API (REST) looks like this
{"data":
{
"field_1": "value_1",
"field_2": "value_2",
"repetitionField(1)" : "fieldValue",
"Orders::OrderDate.0":"12/22/2015"
}
}
The last attribute Orders::OrderDate.0 sets a value to a field on a related record and since the record donĀ“t already exist it will be created.
My question focus on the .0 suffix of the attribute name. It looks to me like the 0 indicates a serial/identifier for on which related record the value should be inserted. This leads me to wonder if it is possible to create more then one related record in the same request that creates the parent record.
The below body returns error that the record does not exist, but why can one related record be created but not two?
{"data":
{
"field_1": "value_1",
"field_2": "value_2",
"repetitionField(1)" : "fieldValue",
"Orders::OrderDate.0":"12/22/2015",
"Orders::OrderDate.1":"11/11/2011"
}
}
Any clue if the above code should work? Am I missing something?
I am fully aware that I can (should) post several requests aimed at the related tables layout to create the related records. I just wish to know, since the .0 notation is in the documentation, does it should have a valid function?
Found this under the notes section in the doc you linked to:
"Only one related record can be created per create record call."
So there you have it. Looks like it behaves similarly to record creation from a portal, where you also can only create one related record at a time.

restrict duplicate entry,iphone

HI All,
i am inserting , say name to sqlite, than showing it on tableview.
But i want say restrict user to insert duplicate name.
for first time data gets inserted perfectly, but when i insert it on second time, it again get inserted, thats what i want to prevent.
HOw can i check if the value 'name' already exist in sqlite and show alert to tell user that this value already exist.
edited
i have an array abc , having few values., values in array i am adding from another view, now say if abc contains value "a1", now if i again inserting "a1", it should not except "a1", in a way how i can restrict an array to add duplicate value.
regards
Use unique constraint in your SQL database. Here's a link with some basics on it. Here's some specifics on how to create table with unique contraints with SQLite.
To alert users, just capture the error message from your SQL query and then output as needed.
Edited (for new question):
Easiest way is to parse through the array and do duplicate checks. There's logic out there for faster searching but if you have a small array, then all you really need is a for loop that iterates through each array element and checks that the new value you are adding is not already there.