Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Button to Open Quick Form

(0) ShareShare
ReportReport
Posted on by 927

Hi,

In CRM Online, I'm trying to build a button to open a "quick create form" from the "Customer Assets" forms which will open the "Case" Quick Creation form in the screen.

I sadly can't get my button to work from the button (nothing happens on the screen) so I tried to add the code to the "OnLoad" of the form and it's throwing an error.

2017_2D00_09_2D00_14_5F00_07_2D00_41_2D00_39.jpg

I was wondering if someone has a clue on what I'm doing wrong, here is the code I'm trying to execute, I took the examples from internet and added the function "OpenQuickCreateCase()" which I'm calling either from the button Command or from the OnLoad when I'm trying to test the code. :

//lookup object of current account record
function openQuickCreateCase()
{
	var custAsset = {

	 entityType: “msdyn_customerasset”,

	 id: Xrm.Page.data.entity.getId()

	};

	var parameters = {};

// *** Call the Xrm.Utility needed to add a contact.
Xrm.Utility.openQuickCreate("incident", custAsset, parameters).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error);});
}

// *** Function called on success.
function successCallback(lookup) {
	alert("lookup: " + lookup.savedEntityReference.id);
	alert("lookup: " + lookup.savedEntityReference.name);
}

// **** Function called on error.
function errorCallback(e) {
	alert("Error: " + e.errorCode + " " + e.message);
}

Thanks in advance for your help!

*This post is locked for comments

  • Loic Orue Profile Picture
    Loic Orue 927 on at
    RE: Button to Open Quick Form

    Thanks Guido and Alex, the issue was indeed the smart quotes. The button and the OnLoad are working perfectly now!

    I should stop using Notepad++ and get an IDE...

  • ashlega Profile Picture
    ashlega 34,477 on at
    RE: Button to Open Quick Form

    Hi,

     when I pasted that code to my Visual Studio, it gave me a syntax error for this line:

    entityType: “msdyn_customerasset”,

     (wrong quotes).. Maybe try this code and see if it makes any difference:

    function openQuickCreateCase()

    {

       var custAsset = {

           entityType: "msdyn_customerasset",

           id: Xrm.Page.data.entity.getId()

       };

       var parameters = {};

       // *** Call the Xrm.Utility needed to add a contact.

       Xrm.Utility.openQuickCreate("incident", custAsset, parameters).then(function (lookup) { successCallback(lookup); }, function (error) { errorCallback(error);});

    }

    // *** Function called on success.

    function successCallback(lookup) {

       alert("lookup: " + lookup.savedEntityReference.id);

       alert("lookup: " + lookup.savedEntityReference.name);

    }

    // **** Function called on error.

    function errorCallback(e) {

       alert("Error: " + e.errorCode + " " + e.message);

    }

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,073 Moderator on at
    RE: Button to Open Quick Form

    you have smart quotes ”” on the entityType

    entityType: “msdyn_customerasset”

    try set single quotes (') or double quotes (")

    entityType: "msdyn_customerasset"


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans