And This needs to be implemented on On-Premise Version not an Online Version.(I have implemented this using Power Automate but as far as i know Power Automate is only for an Online Version).
Hello Syed,
To achieve the scenario described you can build a plugin that will be registered on the Post Operation of Create/Update of a Contact.
Using the plugin context you can get the values of the contact fields using the below as example:
var new_internationalcustomer_contact = (Boolean)entity.Attributes["new_internationalcustomer"];
var new_country_contact = entity.Attributes["new_country"].ToString();
var new_currencyfield_contact = ((Money)entity.Attributes["new_currencyfield"]).Value;
var new_contactmethod_contact = ((OptionSetValue)entity.Attributes["new_contactmethod"]).Value;
After that you can use Query Expression to retrieve the configuration records like:
QueryExpression configurationrecords = new QueryExpression("new_configuration");
configurationrecords.ColumnSet = new ColumnSet("new_internationalcustomer", "new_country", "new_currencyfield", "new_contactmethod", "new_entity");
configurationrecords.Criteria.AddCondition("new_entity", ConditionOperator.Equal, "Contact");
EntityCollection configuration = service.RetrieveMultiple(configurationrecords);
Then you can get all the details for the mentioned fields like:
var new_internationalcustomer_config = (Boolean)entity.Attributes["new_internationalcustomer"];
var new_country_config = config.Attributes["new_country"].ToString();
var new_currencyfield_config = ((Money)config.Attributes["new_currencyfield"]).Value;
var new_contactmethod_config = ((OptionSetValue)config.Attributes["new_contactmethod"]).Value;
After retrieving all this information for each configuration record retrieved you can compared all the fields values using the sample code below:
if ((new_internationalcustomer_contact == new_internationalcustomer_config) && (new_country_contact == new_country_config) && (new_currencyfield_contact == new_currencyfield_config) && (new_contactmethod_contact == new_contactmethod_config))
entity.Attributes["description"] = "Success and all fields are same";
else{
StringBuilder test = new StringBuilder();
test.Append("Failed ");
if (new_internationalcustomer_contact != new_internationalcustomer_config)
test.Append("new_internationalcustomer ");
if (new_country_contact != new_country_config)
test.Append("new_country ");
if (new_currencyfield_contact != new_currencyfield_config)
test.Append("new_currencyfield ");
if (new_contactmethod_contact != new_contactmethod_config)
test.Append("new_contactmethod ");
entity.Attributes["description"] = test.ToString();
}
service.Update(entity);
Depending on the context where the plugin is registered you might have to adapt this sample code to your scenario.
Refer to:
- itsfascinating.com/.../ - here you will found how to work and get the values for different data type fields.
- docs.microsoft.com/.../plugin-development - On-premise plug-in development
- docs.microsoft.com/.../tutorial-write-plug-in - Tutorial: Write and register a plug-in
Hope this helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156