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

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

Related

Custom field on opportunity object not available in historical table

I have created a custom currency field, in Salesforce, on the standard Opportunity object. It's not a formula field; a workflow updates this field on edit/new opportunity. I have enabled Field History tracking on this field.
I want to include this field on a trend report with 2 snapshots of the field's value. The issue is that I don't see the field's historic value available to be selected under the "Opportunity (Historical)" field list. So, it seems like the value has not been added to this related object. (I can see the other standard fields' snapshot values.)
I went to the Report Type to see if I could add it there, but again, it's not available to be selected; only the field that's in the actual opportunity is selectable.
What steps have I missed?
if your field history report isn’t returning any records even though you know that records have changed, then ask your admin to turn on field history tracking.
Resource:
https://trailhead.salesforce.com/content/learn/projects/customize-a-salesforce-object/account-field-history-tracking
https://help.salesforce.com/s/articleView?id=sf.reports_filter_old_value_new_value.htm&type=5
PDF:
https://resources.docs.salesforce.com/latest/latest/en-us/sfdc/pdf/field_history_retention.pdf

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 select a column from table/collection using odata URI?

I am using mongodb and odata.
I want to select name field alone for particular user id. (i.e) select name from userdata where userid=1;
/*my collection schema - userdata*/
{
id:number,
userid:string,
name:string,
data:object
}
I tried http://localhost:27017/userdata?$format=json&$filter=userid eq '1'&$select=name
Instead of getting name file alone I got whole object/document that matches userid=1. What I am doing wrong here?
I spoted the problem after the comment from #jps.
The issue is not with query, the problem is with data model which I am using is mismatching with my database schema (i.e) I missed out name field in model, so it is returning whole collection.
Now model is fixed, so the service is responding back with names for given userid.

Restrict Custom Field Value Responses for Contacts

When sending a GET query for matters, you can use the custom_field_ids[] key with a custom field id as the value to pull down the fields for a specific custom field assigned to a matter.
The documentation shows no similar functionality for the contact object. I'm having to pull all custom_field_values{field_name,value} and parse this result to find the specific custom field value I'm looking for, when I'm querying a contact.
Is there a better way to get the custom field value for a specific custom field id for contacts than what I'm doing above? If not, I'd love to see the custom_field_ids[] parameter applied to the contact object.

How to retain the value of an editable text field in a Lotus Notes form every time the user opens it?

I have a form in Lotus Notes containing an editable text field.
Once the user enters a value in that field, it gets saved properly when I check it by opening the document from the back-end.
But I need this value to be seen in the form every time the user opens the form.
Because it is a configuration form where the user should be able to see all the values saved.
For example, a field which contains the path to download a report. And it should be an editable field itself. Is there any way to do this? Any sort of clue or help would be really appreciated. Thanks in advance!
The value of an editable field stored in a document does keep it's value every time the user opens the document.
It sounds like you may ask for something else. You want User A to create a document, enter a value (i.g. a download path) and save the document. When User A or User B later creates another document based on the same form, the previously entered value should be the default. Is that what you mean?
In that case you could simply use #DbLookup or #DbColumn in the formula language in the Default Value property of the field.
Or create a lookup view with the previously created document, sorted descending by date, then use the GetFirstDocument method of the NotesView class to get the first document in that view and read the value out of it using the GetItemValues method of the NotesDocument class.
Performance tip: If you make sure the value you want to look up is visible in the lookup view you can use the GetFirstEntry method of the NotesView class, then use the ColumnValues property to get the value, this is much faster.
Solution is to use #DbColumn in the default value of the editable text field of my form