I have a collection that contains a text field called eventtype . I have 4 different types of events that correspond to dynamic pages. What I would like to happen is after I create an event in the collection, the data hook will use the eventtype to copy the dynamic url from the correct column and put it into a new column called dynamicurl . For example, if the eventtype is Open Tournament, then the dynamicurl field contains the URL from Events Opens (Season, Title) . Here is a sample of the collection:
and here is what my data hook currently looks like. The editor did not like the item.link-Events-… without the quotes surrounding it. Is my syntax correct? Should this be a different type of hook? Thanks in advance!
export function Events_afterInsert(item, context) { switch (item.eventtype)
{ case “Club Tournament”:
item.dynamicurl = “item.link-Events-Tournaments-season-title”; return item; case “Open Tournament”:
item.dynamicurl = “item.link-Events-Opens-season-title”; return item; case “Meeting”:
item.dynamicurl = “item.link-Events-Meetings-season-title”; return item; case “Officers Meeting”:
item.dynamicurl = “item.link-Events-Meetings-season-title”; return item; case “Special”:
item.dynamicurl = “item.link-Events-Special-season-title”; return item; default :
item.dynamicurl = “item.link-Events-Tournaments-season-title”; return item;
}
}
Thank you! I have updated that and I see the fields updating, however I am not sure how to reference one of the dynamic url pages. When I try to use item. link-Events-Opens-season-title, I get an error because it thinks Events and Opens and season are variables
Thanks. The main issue I am having is that the fieldname is not being interpreted correctly. It throws an error when I use item.link-Events-Opens-season-title or any of the dynamic read only column field names