Hi all,
Having some trouble with this piece of code. I have adapted it from https://msdn.microsoft.com/en-us/library/gg334427(v=crm.7).aspx
I have a custom entity that is called "Gallery Settings". On the prevalidation of the creation of a new Gallery Settings record, I have created a plugin to create a new entity (not a new record, a new custom entity) based on the information selected. If I create a new record by looking at the Active Gallery Settings view and click New Record and fill in the info, the new entity is generated correctly - the plugin works.
Now I'm on to the next part: an HTML/JS webresource that presents a list of all currently existing galleries, and provides the option to make a new gallery from a list of entities retrieved with SDK.Metadata.RetrieveAllEntities.
The code:
//Action to take when Create button is clicked on modal function createGallery() { //Get selected entity var selectedEntityGuid = $("#entityList option:selected").val(); var selectedEntityName = $("#entityList option:selected").text(); alert("Creating gallery for "+selectedEntityName+" which has Guid "+selectedEntityGuid); //Create new Gallery record object var gallery = {}; //Populate fields //Gallery Name gallery.jcts_name = selectedEntityName+" Image"; //Related Entity Name gallery.jcts_RelatedEntityName = selectedEntityName; //Related Entity Guid gallery.jcts_RelatedEntityGuid = selectedEntityGuid; //Create record in CRM. This will trigger the plugin to create the new entity. SDK.REST.createRecord(gallery,"jcts_gallerysettings", successCreateGallery, errorCreateGallery); } function successCreateGallery() {alert("Success");} function errorCreateGallery(error) { alert(error); }
This code seems to return "500: Internal Server Error: the given key was not present in the dictionary"
Seems like a misspelling somewhere. I've checked all my attribute names are correct, the entity name jcts_gallerysettings is correct, I just cannot get this to execute.
I was reading that it might be a problem with my plugin, but I've checked it all over too and can't find any misspellings, and of course if I make the record manually then the new entity is indeed generated, so the plugin seems to work fine.
Any ideas anyone??
I've tried commenting out the lines that add the attributes to gallery{} and I get the same error. try uncommenting one at a time, same thing. seems like it doesn't like the name of my custom entity or something? Is there a way to see exactly what "given key" it's having issues with?