How to enable plugin trace logs programatically / via SDK - dynamics-crm

I know how to enable plugin trace logs via UI - i.e.
Is there a way how to do it programatically (via SDK call) ?

Yes, it is possible, Plugin Trace Viewer for XrmToolBox has the option to change the logging level.
From the source code, it should be an update to the organization entity, field plugintracelogsetting (optionset with the following options: Off = 0, Exception = 1, All = 2)
The organization entity should have only a single record, so you do a RetrieveMultiple and check the first result in order to get the Id for the entity update.
 

Related

Dynamics 365: Prevent firing plugin execution while updating record

I want to update a field without firing the plugin execution. I tried to update it with SQL 4 CDS, but the plugin executes and I get a timeout error (This plugin is updating all child records, but at this case we want to bypass this). Is there a way to achieve this?
In C# you can actually do this using an UpdateRequest.
You would create the request like this:
var request = new UpdateRequest
{
Target = entity,
["BypassCustomPluginExecution"] = true
};
Important note: users must have the prvBypassCustomPlugins privilege to make this work. This privilege cannot be assigned through the UI and only the System Administrator role has this privilege by default.
See also Bypass Custom Business Logic - MS Learn.
I found a way to update record without triggering plugins. At SQL 4 CDS, in Settings menu there is an option "Bypass custom plugins" as you can see at the screenshot below. By checking this option, you can update the record without triggering plugin execution

Form displays blank fields instead of DB data values

I have a from with a plugin that updates a record in the DB. I see the updated data in the record in the DB, but when i load the form the updated data does not show.
there are no business rules, the is no JS OnLoad event.
The record is inactive in the DB when the data is updated, but i don' think that should matter
Any ideas as to what I am overlooking?
You're correct that the changes should still save to an inactive record.
Under Advanced Settings > Administration > System Settings > Customization you can set "Enable logging to plug-in trace log" to "All".
Then in the plugin you can use the ITracingService to log messages, which are then visible in Advanced Settings > Plugin-In Trace Log.
You could log the fields' values before and after you set them to confirm that they're getting set.
Or, for a "quick and dirty" option store the fields' values before you set them, then after you set them, throw an InvalidPluginExecution exception containing the "before and after" values. The exception message will pop up right in the UI.
We'd be better able to analyze the issue if you post your code.
On a related note, when writing plugins I often separate the logic out into a Visual Studio Shared Project. I reference that project from a console app and the plugin assembly. The console app enables me to test and debug locally with full VS debugging capabilities before publishing the plugin. Of course there are certain things from the context that can be tricky to mock in the Console app, so your mileage may vary depending on the application.
There are also testing frameworks like FakeXrmEasy, but I have yet to try any of those.

You can not complete this action for this component because of the configuration of its managed properties

I am trying to make a field optional in the Dynamics CRM
The name of the entity is Case and the internal name of the field is customerid
When I try to change it from mandatory to optional, I get the below error message
You can not complete this action for this component because of the
configuration of its managed properties.
this is happening in Dynamics CRM online
I'm pretty sure you won't be able to.
It's one of the few fields where mandatory behaviour is enforced at the platform level, whilst most mandatory fields are enforced only on the user interface.
If I remember correctly, tring to create a case without a customer via the API will result in an exception.
Looking at the managed properties for the customerid field on my recently provisioned CRM Online, shows that I'm unable to change the requirement level - I don't even get the option for setting it as optional.
I wanted to remove the field from the form, but I was not able to do it from the UI
So I used XRMToolBox.
There is a plugin called as FormXML Manager, enable it in the XRMToolBox and load the entities. Once this is done you can remove the required field and publish the form

Is it possible to get parameters of an unpublished plugin without querying the database directly?

Is there a Joomla 2.5.x API that would allow for retrieval of a plugin information(i.e. parameters) if the desired plugin is unpublished?
Why: We have a few plugins that are only enabled in production and I'm looking for a way to get at some of the parameters programmatically and without querying the database directly.
Try something like
$userPlugin = JPluginHelper::getPlugin('user', 'joomla'); // group, specific - optional
$userPluginParams = new JRegistry();
$userPluginParams->loadString($userPlugin->params); //get the string as a jregistry
$useStrongEncryption = $userPluginParams->get('strong_passwords', 0); // get the one you want.
Here's a workaround to make it not run but still able to get:
Okay how about this for a trick/workaround. Did you realize plugins have access levels? Why don't you create an access level with no one in it and assign to the plugin as the only level it runs for. Then you can publish it but it won't run.

How can I get trace of my linq query (using linqtotwitter on windows 8 app in c# and xaml)

I'm developping a Windows 8 metro app using linqtotwitter.
I need to get a trace of my linq queries in my log file but I searched and didn't find hox can I do this.
Everything that I read speak about linq to sql, with a database, I don't have a database.
I get information by querying the Twitter API via linqtotwitter.
How can I get a trace of my query?
My code:
User usersResponse = new User();
usersResponse = (from user in twitterCtxProp.User
where user.Type == UserType.Lookup &&
user.ScreenName == name
select user).SingleOrDefault();
It's open source, so check the source to see if the developer used Systems.Diagnostics trace, nlogger or some other logging framework. If so with some web.config edits you can view the trace. If he used outputdebugstring, you can use debugview http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx to see the trace.
If he didn't instrument the library for trace, (not all developers buy into the idea of trace), then you'd want to pick your favorite library and add some trace commands.
And finally, if you are interested in the final result (but not how the library go there) use fiddler to see what goes across the wire to twitter: http://www.fiddler2.com/fiddler2/

Resources