Ajax Call from Other page

I have this code in page_load in Mail form as in phpmaker document "

    $this->CustomActions["Archive"] = new ListAction(
        "Archive",
        "Archive",
        IsLoggedIn(),
        ActionType::AJAX,
        ActionType::ACTION_MULTIPLE,
        "Archive the selected record?",
        "fa-solid fa-star ew-icon",
        "",
        fn($row) => $this->update($row, ["ID" => $row["ID"]]), // Update the current record only (the second argument is WHERE clause for UPDATE statement)
        "Archived successfully",
        "Failed toArchive"
    );

Is the any way to call this ajax custom action from other form ?
i need to update record from other form

I don’t think you can do that in other than List Page, since that Custom Action will use ListAction object which is belongs to the List Page itself.

1 Like

You may use ew.submitAction(), from the source code, the function arguments are:

  /**
   * Submit action
   *
   * @param {MouseEvent} e - Mouse event
   * @param {Object} args - Arguments
   * @param {HTMLElement} args.f - HTML form (default is the form of the source element)
   * @param {string} args.url - URL to which the request is sent (default is current page)
   * @param {Object} args.key - Key as object (for single record only)
   * @param {string|Object} args.msg - Message or Swal config
   * @param {string} args.action - Custom action name
   * @param {string} args.select - "S" (single record) or "M" (multiple records, default)
   * @param {string} args.method - "A" (Ajax by HTTP POST) or "R" (Redirect by HTTP GET) or "P" (HTTP POST by HTML form, default)
   * @param {Object} args.data - Object of user data that is sent to the server
   * @param {string|callback|Object} success - Function to be called if the request succeeds, or settings for jQuery.ajax() (for Ajax only)
   * @returns
   */
  function submitAction(e, args) { ... }