Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Javascript to open a related quick-create form

$
0
0

Hello,

I've been working on a javascript snippet that when you click on a button from the ribbon, it opens new quick create form for a related record. It is a custom entity, and I've created a 1:N relationship, where the Opportunity can have many of these "contact attempt" records tied to it. I'm super close with the code, but I cannot get the related opportunity to populate on the form. When you click the button on an opportunity's ribbon, it should populate that opportunity into the form, but It opens without that value every time. I've worked through a couple of suggestions here in the forum, including adding an onload action (based on this: https://butenko.pro/2020/09/15/js-how-to-get-the-originating-record-reference-in-the-form-script-of-the-quick-create-form/) and using the XRM open form utility (following this: https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg334375(v=crm.8)) But it's just not working. 

Below is my code snippet. Any help/ideas would be appreciated. (aaaaa = replacing the company name in the code)

function contactAttemptQC() {    var entityFormOptions = {};
entityFormOptions["entityName"] = "aaaaa_contactattempt";
entityFormOptions["useQuickCreateForm"] = true;

var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
var yyyy = today.getFullYear();

var formParameters = {};
formParameters["name"] = "Contact Attempt";
formParameters["aaaaa_contactdate"] = today;

// Set lookup column
formParameters["aaaaa_attemptsid"] = "parentRecordReference.id";
formParameters["aaaaa_attemptsidname"] = "parentRecordReference.name";


// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (success) {
console.log(success);
},
function (error) {
console.log(error);
});
}

Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>