0

We display inside a tab in the Sales Console a custom object page layout with a custom Javascript button. Once the user clicks on that button, the custom code performs some operations on a Salesforce custom web service APEX class (by using the script connection.js) and based on the response, eventually opens a new tab in the console (by using the script integration.js). This functionality works fine.

When the system is busy working, not to let the user press the button twice or getting confused about the state of his request, we want to disable the button and display the waiting cursor. So we created the following code inside the button:

var btnService = document.getElementsByName("check_lead_contact");

btnService[0].value='Checking, please wait...';
btnService[0].disabled=true;
document.body.style.cursor = 'wait';

//JavaScript code calling APEX Webservice by using connection.js
//Javascript code opening new Sales Consoel tab using integration.js

document.body.style.cursor = 'default';
btnService[0].value='Check Lead/Contact';
btnService[0].disabled=false;

However this code does not work, the button does not get disabled and the cursor does not change to "wait". However, if I inspect the code with developer tools, I see that in the console the state of the JS variables linked to both the button and the cursor change but such changes are not reflected in the UI. All the changes in the UI are made once the function ends and not the state variable change, as it is supposed to be, most likely because the call to the webservice somehow make the function hangs.

We asked help to SF support that replied to us that they do not offer support for buttons containing references to either connection.js or integration.js, although they are included in official SF documentation. Does anybody know a way to solve this issue?

0

If you do slight modification to your ending lines I hope it works. Can you try this....

document.body.style.cursor = 'default'; btnService[0].value='Check Lead/Contact'; setTimeout(function() {btnService[0].disabled=false;},1000);

Not sure about whether it will change the first two properties (cursor & Value) but it will definitely disable the button. Let me know if it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.