Question

Convert Lookup value into string

   Hi, I am trying to read a lookup value here! Please check my code when I select delivery as Same as Above then the value in address2 should automatically get updated in the result.

 

but the problem is "Delivery" is a lookup value and Bill to the location is a string value while setting the value in it. It is showing undefined.

 

Please tell me how will I convert a lookup value into a String value.

UpdateContatination: function(){

                                                //            var invalidMessage="";

                                                                var delivery=this.get("UsrChooseDeliveryOption");

                                                                if(delivery.displayValue==="Same as above")

                                                                {

                                                                   this.showInformationDialog("Hello");

                                                                                var add={displayValue:this.get("UsrBillToAddress2")};

                                                                  var result=add+""+"abc";

                                                                                this.set("UsrBillToLocationText",result);

                               

                                                                }

                                                },

Like 0

Like

3 comments
Best reply

To set the value in a text field, you don't need to create an object with "displayValue". For example, if you want to read the text of the value in your Delivery lookup and add it to the Location text field, you can do the following:

var delivery = this.get("UsrChooseDeliveryOption");
if (delivery.displayValue === "Same as above") {
    this.set("UsrBillToLocationText", delivery.displayValue);
}

Ryan

To set the value in a text field, you don't need to create an object with "displayValue". For example, if you want to read the text of the value in your Delivery lookup and add it to the Location text field, you can do the following:

var delivery = this.get("UsrChooseDeliveryOption");
if (delivery.displayValue === "Same as above") {
    this.set("UsrBillToLocationText", delivery.displayValue);
}

Ryan

But I am trying to concatenation of string and set to one string like I did in the code : with result variable is that possible?

Bhumika Bisht,

Please feel free to use the construction as in the example below so to concatenate a string:

 

var delivery = this.get("UsrChooseDeliveryOption");

if (delivery.displayValue === "Same as above") {

    this.set("UsrBillToLocationText", delivery.displayValue + " Abc");

}

 

Best regards,

Oscar

Show all comments