Lookup Field Remains Empty when Setting Value with Javascript
-
- Posts: 2
- Joined: Thu Jun 09, 2016
Hi,
Currently in the evaluation period of your products, seems to be working really well for what we're looking for but I'm having an issue with setting a lookup field from javascript.
I have two lists, 1st) Equipment and 2nd) Events assocaited with equipment list. Whenever the status of an equipment changes a new item is created in the Events list to hold the information realted to the status change.
On the Display form of an item from Equipment list I have a set of hyperlinks at the top (hyperlinks pass information like equipment ID, name, and the new status). When a user clicks one of the links on the equipment form they're taken to the a New Event form. I have script on the New Event form which grabs the equipment ID and new status and sets the lookup fields.
The issue is the lookup fields display blank, I know they were correctly set because when I save the event and view the event both the status and equipment are correct. Do you have any tips to figure out why the lookup fields are not dispalying the information? Thank you!
Process:
1) User is directed to Equipment Display Form: https://i.imgsafe.org/ad99e8048b.jpg
2) User slects the hyperlink corresponding to action to carry out (in this example they're clicking "Loaded for Return")
3) User is directed to the "New Event" form with parameters passed including equipment ID and new status: https://i.imgsafe.org/ad99e23b74.jpg
The first field with an "x" in it should display the Title of the equipment from the equipment list, and the next field should contain the new status. Code used to set those fields:
function setEquipmentID() {
var equipID = fd.getUrlParam(decodeURIComponent(window.location.href), 'equipID'); fd.field('Equipment').control().value(equipID); }
function getNewStatus() { var newStatusID = fd.getUrlParam(decodeURIComponent(window.location.href), 'newStatusID'); fd.field('Status').control().value(newStatusID); //alert(newStatusID); }
If I save the form, the correct value is displayed (so I know the code is setting the ID properly, I just can't get the value to display on the New form): https://i.imgsafe.org/ad99d8334d.jpg
Any help would be greatly appreciated, thank you!!
Currently in the evaluation period of your products, seems to be working really well for what we're looking for but I'm having an issue with setting a lookup field from javascript.
I have two lists, 1st) Equipment and 2nd) Events assocaited with equipment list. Whenever the status of an equipment changes a new item is created in the Events list to hold the information realted to the status change.
On the Display form of an item from Equipment list I have a set of hyperlinks at the top (hyperlinks pass information like equipment ID, name, and the new status). When a user clicks one of the links on the equipment form they're taken to the a New Event form. I have script on the New Event form which grabs the equipment ID and new status and sets the lookup fields.
The issue is the lookup fields display blank, I know they were correctly set because when I save the event and view the event both the status and equipment are correct. Do you have any tips to figure out why the lookup fields are not dispalying the information? Thank you!
Process:
1) User is directed to Equipment Display Form: https://i.imgsafe.org/ad99e8048b.jpg
2) User slects the hyperlink corresponding to action to carry out (in this example they're clicking "Loaded for Return")
3) User is directed to the "New Event" form with parameters passed including equipment ID and new status: https://i.imgsafe.org/ad99e23b74.jpg
The first field with an "x" in it should display the Title of the equipment from the equipment list, and the next field should contain the new status. Code used to set those fields:
function setEquipmentID() {
var equipID = fd.getUrlParam(decodeURIComponent(window.location.href), 'equipID'); fd.field('Equipment').control().value(equipID); }
function getNewStatus() { var newStatusID = fd.getUrlParam(decodeURIComponent(window.location.href), 'newStatusID'); fd.field('Status').control().value(newStatusID); //alert(newStatusID); }
If I save the form, the correct value is displayed (so I know the code is setting the ID properly, I just can't get the value to display on the New form): https://i.imgsafe.org/ad99d8334d.jpg
Any help would be greatly appreciated, thank you!!
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Thank you for the question.
Cross-site Lookup does not load all items from the source list at once, so it cannot populate a title by the ID. You should pass the title via query string as you do with the ID. Then set both, the ID and title following way:
Cross-site Lookup does not load all items from the source list at once, so it cannot populate a title by the ID. You should pass the title via query string as you do with the ID. Then set both, the ID and title following way:
Code: Select all
function setEquipmentID() {
var equipID = GetUrlKeyValue('equipID');
var equipTitle = GetUrlKeyValue('equipTitle');
fd.field('Equipment').value([equipID + ';#' + equipTitle]);
// or for a single-value lookup:
// fd.field('Equipment').value(equipID + ';#' + equipTitle);
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests