You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maximo 7.6.1.2中如何通过自动化脚本调用直接打印对话框?

Automating Direct Print Dialog in Maximo 7.6.1.2 with Action Launch Points

Hey there! Great question—you absolutely can automate the direct print dialog trigger after running validation logic via an action launch point in Maximo 7.6.1.2. Using webclientsetsession() is the right approach here, since it lets you pass server-side state to the client to trigger the print action. Here's a step-by-step breakdown tailored to your use case:

1. Set Up Your Action Launch Point with Validation Logic

First, configure your action launch point to run your validation before triggering print:

  • Bind the action to your target object (e.g., WORKORDER for work orders) and set the trigger to match your button click event.
  • In the Script tab of the action, write your validation logic first. If validation fails, throw an error and exit the script to prevent printing:
// Example: Validate work order status before printing
var woStatus = mbo.getString("STATUS");
if (woStatus !== "APPR") {
    service.error("Work order must be approved to print!");
    return false; // Halt further execution if validation fails
}

2. Use webclientsetsession() to Flag Print Trigger

Once validation passes, use webclientsetsession() to set session-level flags that the client will pick up to launch the print dialog. This bridges the server-side action script to the client-side print functionality:

// Mark that direct print should be triggered
webclientsetsession("TRIGGER_DIRECT_PRINT", "true");
// Optional: Pass context about what to print (adjust based on your object)
webclientsetsession("PRINT_OBJECT", "WORKORDER");
webclientsetsession("PRINT_RECORD_KEY", mbo.getString("WONUM"));

3. Add Client-Side Script to Listen for Print Trigger

Since the action runs server-side, you need a client-side script (in your application's launch script or a custom control) to check the session flag and trigger the print dialog:

// Add this to your application's launch script (Application Designer > Application > Launch Script)
addLoadEvent(function() {
    var shouldPrint = getSessionValue("TRIGGER_DIRECT_PRINT");
    if (shouldPrint === "true") {
        // Retrieve print context from session
        var printObject = getSessionValue("PRINT_OBJECT");
        var recordKey = getSessionValue("PRINT_RECORD_KEY");
        
        // Configure print parameters (adjust report name and app to match your setup)
        var printConfig = {
            appName: "WORKORDER",
            objectName: printObject,
            whereClause: `WONUM='${recordKey}'`,
            reportName: "WORKORDER_REPORT", // Replace with your actual report name
            directPrint: true // Enable direct print mode
        };
        
        // Trigger Maximo's built-in print API
        MXPrint.printReport(printConfig);
        
        // Clear the session flag to avoid repeated prints on page refresh
        setSessionValue("TRIGGER_DIRECT_PRINT", "false");
    }
});

Key Notes for 7.6.1.2

  • Report Configuration: Ensure your target report has the "Direct Print" option enabled in Report Designer—this is required for the directPrint: true parameter to work.
  • Session Flag Cleanup: Always reset the TRIGGER_DIRECT_PRINT flag after printing to prevent accidental re-triggers if the user refreshes the page.
  • API Compatibility: MXPrint.printReport() is a native Maximo API in 7.6.1.2, so you don't need to include any external libraries.

内容的提问来源于stack exchange,提问作者max092012

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 20:07:31