Dear community,
I am trying to open a dialog in order to create a new child item in a sublist (child list). All works well, I get the variable back, but for some reason the partnerContactLookup is not found in the parent list.
This is my JS for the Parent list:
fd.spRendered(function () {
window.openPartnersKontaktyForm = () => {
const listId = '{e48958b0-4617-4075-93a6-e8daef445ee2}';
const siteUrl = 'https://corwin.sharepoint.com/sites/DMS';
const newFormUrl =
`${siteUrl}/_layouts/15/listform.aspx?PageType=8&ListId=${encodeURIComponent(listId)}`;
const partnerLookup = fd.field('Partner').value; // {LookupId, LookupValue}
const IDPartnera = partnerLookup?.LookupId;
Dialog.open(
newFormUrl, {
IDPartnera
},
async(saved, payload) => {
if (saved && payload?.newItemId) { // child sends {ID: newItemId}
console.log('New contact ID:', payload.newItemId);
const contactId = payload.newItemId;
await addNewContact(contactId); // ⬅️ correct invocation
}
}, {
width: 1000,
height: 900,
title: 'Create related record'
});
};
/* Helper */
async function addNewContact(contactId) {
const lookup = fd.field('PartnerContactLookup');
if (!lookup) {
console.error('Control “PartnerContactLookup” is missing or mis-named.');
return;
}
await lookup.refresh();
lookup.value = {
Id: contactId,
LookupId: contactId
};
}
});
This is the JS for child list:
fd.spRendered(() => {
if (Dialog.getHost() !== window) {
const args = Dialog.getArgs();
if (args?.IDPartnera) {
fd.field('IDPartnera').value = args.IDPartnera;
fd.field('IDPartnera').disabled = true;
// fd.field('IDPartnera').value = String(args.IDPartnera);
}
}
});
fd.spSaved(result => {
const payload = {
newItemId: result.Id,
contactName: fd.field('Title').value
};
Dialog.close(true, payload);
});
I can see this in the console:
New contact ID: 698
Control “PartnerContactLookup” is missing or mis-named.
Any other action that would use the column fails.