Validates the link to a document by checking the specified fields.

This function performs an asynchronous request to the server to validate the link to a document, based on the given doctype, docname, and optional fields. The validation ensures that the document referenced by the link exists and that the specified fields are correctly linked.

// Validate the link for an 'Employee' document, checking specific fields.
const validationParams: validateLinkParams = {
doctype: 'Employee',
docname: 'EMP-001',
fields: ['manager', 'department'],
};
const validationResult = await validateLink(validationParams);
console.log(validationResult); // Logs the validation result, which may include errors or confirmation of valid links
// Validate the link for a 'Project' document without specifying fields.
const validationParams: validateLinkParams = {
doctype: 'Project',
docname: 'PRJ-2024',
};
const validationResult = await validateLink(validationParams);
console.log(validationResult); // Logs the validation result for the document

Throws an error if the request fails or if there is an issue with validating the document link.

  • Parameters

    • params: validateLinkParams

      The parameters for validating the document link. This includes:

      • doctype: The type of document to validate the link for.
      • docname: The name or identifier of the document to validate.
      • fields (optional): An array of field names to be validated. If provided, only these fields will be checked for link validation.

    Returns Promise<any>

    A promise that resolves to the result of the link validation. The result typically contains relevant information about the validation status or errors if any fields are invalid.