Trying to retrieve lookup values

I am trying to retrieve the values from a lookup column and the information I have coming across with it I have tthe alerts there just so I can see that I am returning the correct values. Currently my code does nothing....
function displayLookupValues() {
var barcodeNumber = fd.field('Barcode_x0020_Number').control();
var title = fd.field('Barcode_x0020_Number_x0020_LU_x0').control();
var price = fd.field('Barcode_x0020_Number_x003a_Price').control();

    alert('Barcode Number: ' + barcodeNumber.value);
    alert('Title: ' + title.value);
    alert('Price: ' + price.value);

fd.spRendered(function() {

got this working so jus in case its of nay help this worked:

 fd.spRendered(function() {
    function updateFields() {
        var quantity = fd.field('Quantity').value || 0;
        var barcodeField = fd.field('Barcode_x0020_Number');
        if (barcodeField) {
            barcodeField.ready().then(function() {
                var price = barcodeField.value.Price2 || 0;
                var prod = barcodeField.value.Title;
                var cost = quantity * price;
                fd.field('Cost').value = cost;
                fd.field('Title').value = prod;
                fd.field('Price').value = price;
    fd.field('Barcode_x0020_Number').$on('change', updateFields);
    fd.field('Quantity').$on('change', updateFields);

after adding the fields in after adding the fields in teh extra fields section

If there is a more efficient or a better way to do this please feel free to let me know

1 Like