CRM 2013 : Replace Look up value Name and auto populate in Single line of Text. RRS feed

  • Question

  • Hi ,

    I have a requirement like I need to Replace the exiting Look up value name and auto populate in new field which is the data type as Single line of text. For this I have written the below Jscript but I'm getting the error of object doesn't support to the Replace.

    Can some one help me on this where I'm doing mistake to get my results.

    REQ: look up value contains the Name like CustomerABC - Sales.

    I need to populate the Name in Single line of text is like CustomerABC  I need to remove the "- Sales" from the lookup 

    function RemoveCustomerName() {
    //getting the look up values
        var RemCustomer = Xrm.Page.getAttribute('new_customer').getValue();
    //checking the look up null or Not
        if (RemCustomer != null) {
         //getting the name look up name into String  
            var RemoveSalesStr = RemCustomer[0].name;

            // Replacing the look up value
            var CustomerReplaceSalesStr = RemoveSalesStr.Replace("RemCustomer[0].name", "- Sales", "");


    • Edited by Rahul-22 Thursday, November 12, 2015 10:06 AM
    Thursday, November 12, 2015 10:06 AM


  • I got the solution,

    here is my mistake

    var CustomerReplaceSalesStr = RemoveSalesStr.Replace("RemCustomer[0].name", "- Sales", "");

    Modified :

    var CustomerReplaceSalesStr = RemoveSalesStr.replace("- Sales", "");


    Thursday, November 12, 2015 10:50 AM