No internet connection
  1. Home
  2. How to

Need help with a Preview enabled warning script

By Lucas Frisch @Lucas_Frisch
    2022-05-02 16:48:45.275Z

    Hi ,
    I had no luck finding help in the ideas forum category so i try here..
    The idea is to display a different surface on a device whether Preview is on or off
    gathering piece of code here and there i managed to display a surface with preview on and log preview off , but as soon as i add the second surface for preview off , everything goes sideways..

    here what i have :

    this works :

    
    //Button
    var previewAutomationBtn = sf.ui.proTools.automationWindow.buttons.whoseTitle.is('Enable Auto Preview Mode').first;
    
    //Check if button is enabled
    if (previewAutomationBtn.invalidate().value.value == "Selected") {
    sf.surfaces.get('user:cl1tm5xan000cng10ohmfnl97:cl1tm65u1000dng10tv58qn5w').open({
        device: sf.devices.mobile.getByDeviceId('mobile.25bbc8803fdd3389--Galaxy-S9-de-Lucas'),
    });
    } else {
        log("Automation Preview is not enabled");
    }; 
    

    but this doesn't :

    sf.ui.proTools.appActivateMainWindow();
    
    //Button
    var previewAutomationBtn = sf.ui.proTools.automationWindow.buttons.whoseTitle.is('Enable Auto Preview Mode').first;
    
    //Check if button is enabled
    if (previewAutomationBtn.invalidate().value.value == "Selected") {
    sf.surfaces.get('user:cl1tm5xan000cng10ohmfnl97:cl1tm65u1000dng10tv58qn5w').open({
        device: sf.devices.mobile.getByDeviceId('mobile.25bbc8803fdd3389--Galaxy-S9-de-Lucas'),
    });
    } else {
     sf.surfaces.get('user:cl1tm5xan000cng10ohmfnl97:cl1tmex7x000lng109pifex9x').open({
        device: sf.devices.mobile.getByDeviceId('mobile.25bbc8803fdd3389--Galaxy-S9-de-Lucas'),
    });
    

    I suspect it's coding basics but that where i am at..

    for now my the script is set to an application trigger but is there a way to SF to monitor the preview state constantly? without making everything buggy or slow obviously?

    link to the original thread :

    i 'm don't know java at all to any help pointing me in the right direction would deeply appreciated..

    Thanks all!

    Lucas

    • 0 replies