We have written plugin for Microsoft CRM that is run after an entity is created, and ideally we would like it to run after it has been saved to the database as well. If we set it to process synchronously it fires before our database trigger has had time to modify the entity record.
If we set the plugin to process asynchronously is it assured to have been saved to the database before the plugin is fired, or is there a possible race condition there?
Did you set your own triggers on CRM database tables ? It is not advisable to do so; all operations on the database should be done through the CRM webservice to ensure you're not breaking anything. Also, custom triggers are not guaranteed to survive when CRM Update Rollups are installed. You should always use plugins instead.
Other than that, an asynchronous plugin only fires after the database update is through, as does a synchronous plugin in the post stage; the difference is that the operation (CRM webservice call, saving the CRM form etc.) does not block until the plugin has run, so in the case of saving a record's form, the form will not usually reflect the changes an asynchronous plugin makes because the plugin has not run when the form starts reloading after the postback.
Related
res.config.settings model is TransientModel and TransientModel are designed to be stored temporary data, After periodically time it will remove data from the database. For saving those settings we have to implement set_param and get_param method of ir.config_parameter.
So, Here I want to know why odoo used ir.config_parameter to store those setting values. Why we can't make res.config.settings as Model instead of TransientModel and store data into that model.
I'm not odoo so I cannot answer for them, but I can explain you why I consider this logic.
In odoo, you have the traditional MVC paradigm, but there are places where you don't really have a model: you just want a view and a controller. This is the case for wizards in odoo. Wizards are just helper dialogs to let the user perform hard tasks in an easier way.
However, if they have no model, how to define the data they use? Where to attach controller logic? It would be very hard and would request a whole new programming paradigm inside odoo, so they took an easier solution: transient models.
So in odoo a transient model is basically a wizard. What happens when you open a wizard?
Odoo obtains the view definition.
Calls the controller to obtain default data (default_get()).
Draws a form for you, but there's no record yet in the database.
You can alter the form as usual, and the normal compute and onchange methods work out of the box.
You hit some button in the wizard, to perform any action.
Odoo creates a new record in the wizard table.
The method associated with that button is executed in the server.
The next time you open the wizard, it follows the same procedure. As you can imagine, this creates a lot of records, because a wizard record is always used only once, so there's a cron job that deletes that garbage every now and then. That's why they're called "transient".
The purpose of ir.config_parameter is to store and retrieve database-wide configuration. 1 record = 1 parameter. You can create parameters without using a wizard. These are not transient, so it's the proper place to store parameters.
The purpose of res.config.settings is to help you configure the system, but that's more than just storing system parameters: it involves configuring auth methods, installing modules, giving you shortcuts for mail gateways configuration, installing a theme in each website, choosing a chart of accounts for each company, etc.
It would make no sense to merge all of that in ir.config_parameter.
In SuiteScript 1.0, when calling save we have the option to pass disabletriggers true to avoid running user event scripts from a scheduled script. In my case, I'm using SuiteScript 2.0, and trying to save a vendor record before attaching address and contact details. But, various User Event scripts are triggered which save the vendor record and cause a RCRD_HAS_BEEN_CHANGED error in the original Map/Reduce.
Is there a way to avoid triggering user event scripts in SuiteScript 2.0?
For reference, in SS1.0:
nlapiSubmitRecord(salesorderrecord, {disabletriggers : true, enablesourcing : true});
But this doesn't appear to work in 2.0
It's gone.
It was a sometimes convenient hack but really it should never have been available.
Almost every time I used it I wondered if I was breaking someone else's integration.
In your situation if you have to save the vendor record you should then reload it. If you are passing a record between map reduce stages. Don't. Not only are you potentially ballooning your storage you never have assurance that some other process won't alter your record in between. Even if you check "Submit all stages at once that does not mean other things are not happening that may pick up your record and alter it.
In a CRM 2016 online real-time workflow, is it possible to avoid a record to be updated? In particular i created a real-time workflow of the type "before record status updated", and my objective is that I don't want an opportunity to be activated, if the value of a field of the opportunity is "yes".
Is this behaviour achievable with a workflow, or I need a plugin?
Just for chucks and giggles: As you said it is a real time workflow, you could use a custom workflow activity to throw an error, that would prevent record creation or update as real time workflows are transactional with the create/update operation.
Recommended: Synchronous plugins were put in place exactly for this very reason, to perform business validations and complex business operations.
To use the system as intended, use a plugin.
Not a duplicate of this
I have a pretty simple CRM workflow, which basicly just adds some values to some fields that doesn't get filled whenever a user creates a new object. My challenge here is that a lot of objects are already created in CRM, with a lot of null values. We are talking thousands. So instead of asking the client to open every single object and running the workflow, I was thinking I could create a second workflow which initiates the first workflow to run on all current objects. Is this possible and how should I do it?
The problem is not the workflow execution. Its the selection of the record. Dynamics CRM doesn't have the possibility to execute a workflow against a massive amount of records.
You have to script a little program which selects the records for which you would like to run the workflow and start the workflow for each of them.
See How to run ondemand workflow over all pages
All
Is there any way I can serialize Workflow and save in database and load it later on ?
How can I save instance of workflow in database in C# ?
Thanks
This is called workflow persistence. Here is a simple example to get you started. Essentially, when your workflow idles (there are certain points at which this is possible, e.g. a Delay Activity), if persistence is enabled, your workflow will create a resumption point (i.e. a bookmark), unload and persist to the instance store you've set up (SQL DB, XML file, etc.). When you resume, everything is loaded the way it was before.