f365.context, runtime context

Read-only form context, formId, listId, itemId, displayMode, currentUser, webUrl, siteUrl.

f365.context is a read-only object describing the form's current runtime context. Useful when your code needs to behave differently depending on mode (new vs edit), site, or item id.

Fields

PropertyDescription
formIdThe SharePoint Forms365 form definition id.
listIdGUID of the SharePoint list the form is bound to.
itemIdItem id when editing/displaying; null on a new form.
displayMode"new" | "edit" | "display", what the user is doing.
currentUserSnapshot of f365.user.current() for convenience.
webUrlAbsolute URL of the current SP web.
siteUrlAbsolute URL of the site collection root.

Example

Default values only on new forms

f365.events.onLoad(() => {
  if (f365.context.displayMode === 'new') {
    f365.field('SubmittedBy').value = f365.context.currentUser.id;
    f365.field('SubmittedOn').value = new Date().toISOString();
  }
});

Parent folder (library forms)

f365.folder is the folder a new document is being created in, on a document library form opened in New mode inside a folder. It is null everywhere else: list forms, Edit and Display, and the library root.

PropertyDescription
nameThe folder name.
urlServer-relative URL of the folder.
itemThe folder’s column values by internal name. Text, number, currency, choice and date columns only.

Copy folder values into new documents

f365.events.onLoad(() => {
  if (!f365.folder) return;
  for (const name of ['ParticipantID', 'MPESFirstName', 'MPESLastName']) {
    const field = f365.tryField(name);
    if (field && !field.value) field.value = f365.folder.item[name] ?? '';
  }
});

The values are read once, before the form appears, and only from the folder you are in, not the folders above it. Changing the folder later does not update documents already created. Use the column's internal name.