Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Ribbon Button Issue

(0) ShareShare
ReportReport
Posted on by 5,007

Hi,All

I have created an Ribbon button and when clicked i am not getting dat. please help me to solve the issue

1256.i.PNG

3157.k.PNG

javascript code

function CheckValue()
{
        var contact number = Xrm.Page.getAttribute("new_getdetails").getValue();
        if contact number ( != null)
            return true;
        else
            return false;
setValue();
}

function setValue()
{
Xrm.Page.getAttribute("contact number").setValue("Inactive");  /// You need to write inside double quote

}

*This post is locked for comments

  • Verified answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,393 User Group Leader on at
    RE: Ribbon Button Issue

    Hello Sandeep,

    As I can see you have used the setvalue() function after return statements so it will never execute as your condition will always return either with true or false value.

    However, I have made some changes to your code. Please try to use the below function:

    function CheckValue()

    {

           var detailsAttribute = Xrm.Page.getAttribute("new_getdetails");

    {

    var details = detailsAttribute.getValue();

           if  (details != null)

               return true;

           else

               return false;

          setValue();

    }

    }

    function setValue()

    {

    var contactnumberAttribute= Xrm.Page.getAttribute("contactnumber")

    if(contactnumberAttribure)

      contactnumberAttribute.setValue("Inactive");  

    }

  • sandeepc Profile Picture
    sandeepc 5,007 on at
    RE: Ribbon Button Issue

    ok,do i need to describe in on load or on save event?

  • Verified answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Ribbon Button Issue

    Xrm.Page.getAttribute("contact number").setValue("Inactive"); // In place of contact number place logical name of attribute

  • sandeepc Profile Picture
    sandeepc 5,007 on at
    RE: Ribbon Button Issue

    Uncaught TypeError: Cannot read property 'setValue' of null

       at <anonymous>:1:40

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Ribbon Button Issue

    Simply try to add "Xrm.Page.getAttribute("contact number").setValue("Inactive"); " in console (F12 window) and test whether its working or not directly.

  • Verified answer
    DhananjaySharma Profile Picture
    DhananjaySharma 65 on at
    RE: Ribbon Button Issue

    Hi Sandeep,

    Also you can put alert(""); in your java script code and you can check if it is triggering or not. please call correct function name from ribbon workbench.

    Also there are some correction in code please see below.

    function CheckValue()

    {

           var contactnumber = Xrm.Page.getAttribute("new_getdetails").getValue();

           if (contactnumber  != null)

               return true;

           else

               return false;

    setValue();

    }

    function setValue()

    {

    Xrm.Page.getAttribute("contact number").setValue("Inactive");  /// Here you need to first check datatype of field base on that you can setvalue.

    }

  • sandeepc Profile Picture
    sandeepc 5,007 on at
    RE: Ribbon Button Issue

    i will make any answers as verified

  • sandeepc Profile Picture
    sandeepc 5,007 on at
    RE: Ribbon Button Issue

    hi pravin pawar could you please help me in this to get data . as its production work

  • Verified answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Ribbon Button Issue

    Hi Sandeep,

    Let me clear if I'm wrong here, you are passing function name 'getdetail' where as in your coding function name is  'setValue'.

    Also check where you are passing right data value format for right field. 

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans