In Dynamics CRM, How can I update the CreatedOn date? - javascript

Has anyone had success updating the CreatedOn field in CRM? How can I do this? I've seen a few vague posts saying to use a pre-sync operation, but it'd be helpful to have more information than that.
Any help would be greatly appreciated. Thanks!

It's little tricky.
CreatedOn is system generated field, if you want to preserve the value from some legacy system, then pass the legacy value in overriddencreatedon field. CRM knows you want to put this overriddencreatedon field value in system generated CreatedOn field instead.
This has to be done before DB transaction, and only platform can do that. You can do this with code solution: Pre-operation plugin or no-code solution using CRM import.
PRESERVE OR OVVERRIDE CREATEDON, CREATEDBY, MODIFIEDON, MODIFIEDBY FIELDS
Refer Byron Community Answer
If data is already in CRM, then you have to copy/re-import the new data, at the same time deactivating the old records. You cannot simply update this field in client side (javascript).

Related

Efficiently validate that data on a page hasn't been changed by someone else since you loaded?

We have a page which contains a lot of user editable data that is populated from various tables in a database. The data is in all different forms, dropdowns, checkboxes, input boxes, text areas, etc...
There have been some conflicts where two users load a record around the same time, one makes changes, and then another makes a set of changes. When they save they are unaware someone else made a change and may have just broken a change they made or overwrote their change.
I am trying to implement a solution to mitigate this problem, such as flashing the user an error when the data was changed by someone else.
I am wondering if there is a best practice way to check for this problem? Some ideas I had are
Submit both 'current' data present in the field, and the 'original' data. Then check which are changed and compare them in the database to see if the defaults differ from what is currently saved. This would work, but seems to be the least performance friendly.
Use jquery/javascript to detect when a field has been edited, and if it has changed from defaultValue then set a hidden field which will be submitted to indicate it's original value. Then it would do similar to what the previous idea did.
Set a hidden field with a timestamp of when the user loaded their page. When they submit, use that timestamp and check our history table to see if any data on the page was changed since that timestamp. This seems to be the most efficient idea and likely easiest to implement.
Are there any better options or a best practice way to do this? I feel like I am reinventing the wheel for a common problem.
You are solving a common problem. But it's common because it needs repeatedly solved so frequently. "Optimistic Record Locking" is your path forward. It looks like yii (which I am not familiar with) has capabilities to incorporate handling this. I found this link.
Whether the yii infrastructure does this for you, or you have to build it yourself, what you want to do (to support Optimistic Record Locking) is the following:
Make and Keep an unchanged copy of your data when you retrieve it to the Client.
The Client must submit the changes together with the unchanged copy of the data back to the server.
The Server's 'update' routine compares the unchanged
copy to the current record(s). If something has been changed, then it must
return an error msg and the 'new' current record.
If nothing was changed, then the Server does the update.
The alternative is Pessimistic Record Locking, which you can check out. I avoid it due to other issues it has, but there are scenarios where it is more appropriate.

How to auto-populate when checked / remove info when unchecked

I am very new to programming and I need some help. I am making a billing/invoice program. I would like to be able to populate and unpopulated an invoice by checking or unchecking a company and either one or multiple services. The company names and services are being stored in a database. I know this needs to be done with JavaScript. I have been looking for examples of how to do this on the internet and I can't find anything that use checkboxes. I'm probably making this way harder than what it should be. Any help on how I can do this would be greatly appreciated.
Google's first result on "javascript checkbox" is an answer to your struggle (w3schools link).
you need to do it in few steps 1st. If data is stored in SQL database use PHP to transfer data for json or use PHP to insert data stright in to columns(checkbox labels)
2nd. Data is readable, so lest go for next step if you using JSON insert data in to your label's.3rd. Write some code in JS, you need to create few functions like get checkbox val, load invoice , and some more relative to your case. For sure you will have some trouble with writing code, but you have community, and we are here to help :D Good luck

Roles and read only fields in MS Dynamics CRM

I am using Microsoft Dynamics CRM 2011. We have an entity with a "password" field. This field appears as a MD5 hash. Most users can manually modify this MD5 hash. Some other cannot. I can't find the setting specifying what users can edit this field.
I tried modifying the security roles to align it to a person who can edit the field but it doesn't seem to have any effect on that person. Maybe this is handled at user group level ? I can't find it there either.
Maybe this is coded in a JS script, but I don't find it. Maybe it's done simply in the UI without any script.
Check Field Security Profiles.
Check if any JavaScript has been added to the CRM form.

Django - Dynamic number of ModelForms based on dropdown value

I have a form that registers teams of people. Based on a dropdown to select the number of members in the team, the form should show that many model forms, one for each member.
I am not particularly sure what the correct design patter for this is. Here are the solutions that I have come up with:
Use JS to generate the HTML for each member form and then use the Django ModelForm backend to parse each form. However, in this case I cannot use the inbuilt rendering functions of Django and validation notification becomes bothersome.
Send a GET request whenever the user changes the dropdown value, and the GET request specifies the number of members you want to add. But here it would result in any previously entered data being cleared.
Send a POST request via JS whenever the dropdown is updated, and then re-render the form with the appropriate values picked up from the POST request. I am not sure if this is the right way to do this and seems to be easy to get wrong.
Can you please advise on what is the best solution for this scenario?
I am pretty sure this has already been answered somewhere, but I can't seem to find it anywhere. If you have the link to the answer, please go ahead and mark this question as a duplicate.

CRM Javascript RetrieveMultiple from M:M entity

I need to retrieve fields from all related records into a parent entity. I have got it working in a 1:M relationship, however I can't figure out how to get it working for a M:M relationship, because there is no relationship ID. I need to complete this through javascript. Can anyone help me out?
I'm not sure what version of (presumably) Microsoft Dynamics CRM you are using. I am going to assume you are using 2011. I'm also not fully clear on what you are specifically trying to acheive, but maybe this will help.
CRM 2011 provides an OData endpoint. This blog posting by Mark Kovalcson describes how it can be used.
To get the name and post code of an Account, you would use something like this as your select query:
http://crmserver/MyOrgName/XRMServices/2011/OrganizationData.svc/AccountSet(guid'5B19D04F-C48E-E111-92D4-00155D107003')?$select=Name,Address1_PostalCode
If you wanted to see all instances of child records via the N:N relationship with leads (called accountleads_association) you would use:
http://crmserver/MyOrgName/XRMServices/2011/OrganizationData.svc/AccountSet(guid'5B19D04F-C48E-E111-92D4-00155D107003')/accountleads_association
You can combine the two by using the $expand query option:
http://crmserver/MyOrgName/XRMServices/2011/OrganizationData.svc/AccountSet(guid'5B19D04F-C48E-E111-92D4-00155D107003')$select=Name&$expand=accountleads_association
More details on OData query options here
In order to do this I used an IFRAME and displayed the data through the IFRAME instead pulling CRM information through the query.

Categories