client script - Update lookups

PHOTO EMBED

Mon Jan 05 2026 13:41:41 GMT+0000 (Coordinated Universal Time)

Saved by @usman13

// Get selected Sales Offer
var salesOffer = ZDK.Page.getField("Sales_Offer").getValue();
if (salesOffer == null) {
	ZDK.Page.getField("Project_Name").setValue(null);
	ZDK.Page.getField("Unit").setValue(null);
	ZDK.Page.getField("Office_Location").setValue("");
	return;
}

// Fetch Sales Offer (Quote) details
var quote = ZDK.Apps.CRM.Quotes.fetchById(salesOffer.id);
// ---------------- Project ----------------
var project = null;
var projectID = quote._Projects.id;
var projectName = quote._Projects.name;
// var = proj = quote.Project;
var proj = ZDK.Page.getField('Project_Name');
proj.setValue({
	id: projectID,
	name: projectName
});

if (quote.Projects != null) {
	projectID = quote.Projects;
	project = {
		id: quote._Projects.id
	};
}

var projectID = quote._Unit_Name.id;
var projectName = quote._Unit_Name.name;
var unit = ZDK.Page.getField('Unit');
unit.setValue({
	id: projectID,
	name: projectName
});
console.log(unit);
console.log(project);
// ---------------- Office Location ----------------
var officeLocation = "";
if (quote.Office_Location != null) {
	officeLocation = quote.Office_Location;
}

ZDK.Page.getField("Office_Location").setValue(officeLocation);
content_copyCOPY