locked
Javascript error RRS feed

  • Question

  • Hi All ;

    When i run the code in CRM

    i get message dispalyed as [object Object]-[object Object] on the text field Topic(field name: name)

    Any help much appreciated

    Thanks

    MergeFields=function()
    {
    
    var lookupField = Xrm.Page.getAttribute('parentcontactid');
    
    var lookupField1 = Xrm.Page.getAttribute('new_mainprogramme_id');
    
    var join = lookupField + "-" + lookupField1;	
    
    	if(join != null )
    {
    
    Xrm.Page.getAttribute("name").setValue(join);
    
    }
    
    
    }


    Pradnya07

    Thursday, February 13, 2014 3:25 PM

Answers

  • MergeFields=function()
    {
    
    
    if(Xrm.Page.getAttribute('parentcontactid') != null)
    {
     var lookupField = Xrm.Page.getAttribute('parentcontactid').getValue();
    }
    if(Xrm.Page.getAttribute('new_mainprogramme_id') != null)
    {
    var lookupField1 = Xrm.Page.getAttribute('new_mainprogramme_id').getValue();
    }
    var join = lookupField[0].id + "-" + lookupField1[0].id;	
    
    	if(join != null )
    {
    
    Xrm.Page.getAttribute("name").setValue(join);
    
    }
    
    
    }



    • Edited by CRMDevlpr Thursday, February 13, 2014 3:42 PM
    • Marked as answer by Simran08 Friday, February 14, 2014 2:28 PM
    Thursday, February 13, 2014 3:41 PM
  • If parentcontactid is text field..

    then it should be like this. But i think that parentcontactid is a lookupfield .. not text..

    MergeFields=function()
    {
    
    var lookupField;
    var lookupField1;
    
    if(Xrm.Page.getAttribute('parentcontactid') != null)
    {
     lookupField = Xrm.Page.getAttribute('parentcontactid').getValue();
    }
    if(Xrm.Page.getAttribute('new_mainprogramme_id') != null)
    {
    lookupField1 = Xrm.Page.getAttribute('new_mainprogramme_id').getValue();
    }
    if(lookupField1 != null)
    {
    var join = lookupField + "-" + lookupField1[0].id;	
    
    	if(join != null )
    {
    
    Xrm.Page.getAttribute("name").setValue(join);
    
    }
    }

    • Marked as answer by Simran08 Friday, February 14, 2014 2:28 PM
    Thursday, February 13, 2014 3:58 PM

All replies

  • MergeFields=function()
    {
    
    var lookupField = Xrm.Page.getAttribute('parentcontactid')[0].id;
    
    var lookupField1 = Xrm.Page.getAttribute('new_mainprogramme_id')[0].id;
    
    var join = lookupField + "-" + lookupField1;	
    
    	if(join != null )
    {
    
    Xrm.Page.getAttribute("name").setValue(join);
    
    }
    
    
    }

    Thursday, February 13, 2014 3:27 PM
  • it came up with attached error

    Pradnya07

    Thursday, February 13, 2014 3:33 PM
  • MergeFields=function()
    {
    
    
    if(Xrm.Page.getAttribute('parentcontactid') != null)
    {
     var lookupField = Xrm.Page.getAttribute('parentcontactid').getValue();
    }
    if(Xrm.Page.getAttribute('new_mainprogramme_id') != null)
    {
    var lookupField1 = Xrm.Page.getAttribute('new_mainprogramme_id').getValue();
    }
    var join = lookupField[0].id + "-" + lookupField1[0].id;	
    
    	if(join != null )
    {
    
    Xrm.Page.getAttribute("name").setValue(join);
    
    }
    
    
    }



    • Edited by CRMDevlpr Thursday, February 13, 2014 3:42 PM
    • Marked as answer by Simran08 Friday, February 14, 2014 2:28 PM
    Thursday, February 13, 2014 3:41 PM
  • thanks for your reply

    but again it comes withteh below error

    'parentcontactid' is text field and new_mainprogramme_id is a look up field


    Pradnya07

    Thursday, February 13, 2014 3:46 PM
  • If parentcontactid is text field..

    then it should be like this. But i think that parentcontactid is a lookupfield .. not text..

    MergeFields=function()
    {
    
    var lookupField;
    var lookupField1;
    
    if(Xrm.Page.getAttribute('parentcontactid') != null)
    {
     lookupField = Xrm.Page.getAttribute('parentcontactid').getValue();
    }
    if(Xrm.Page.getAttribute('new_mainprogramme_id') != null)
    {
    lookupField1 = Xrm.Page.getAttribute('new_mainprogramme_id').getValue();
    }
    if(lookupField1 != null)
    {
    var join = lookupField + "-" + lookupField1[0].id;	
    
    	if(join != null )
    {
    
    Xrm.Page.getAttribute("name").setValue(join);
    
    }
    }

    • Marked as answer by Simran08 Friday, February 14, 2014 2:28 PM
    Thursday, February 13, 2014 3:58 PM
  • Referred to this blog
    Friday, February 14, 2014 8:18 AM
  • hi simran,

    Xrm.Page.getAttribute("field name") return as html object like input, lookup etc

    if you use for lookup

    Xrm.Page.getAttribute("field name").getValue() will return an collection

    Xrm.Page.getAttribute("field name").getValue()[0] is your lookup value.

    You can use debugging in IE also.


    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Friday, February 14, 2014 10:45 AM
  • Thanks a load it works like a charm

    Pradnya07

    Friday, February 14, 2014 2:28 PM
  • Good. I need help someone in trouble. Does anyone know how to fix problems java script error?It's a java issue or other problem?

    Wait for response. Thanks.

    Friday, February 14, 2014 3:42 PM
  • Barbara82

    If you need some help with JS..post it as a question on this forum. I am sure, someone will surely come up for ur help

    Friday, February 14, 2014 4:26 PM