Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced Workflow - Rejection Comment Popup

BrianDejno1
Contributor III

Is it possible to have a javascript popup to capture some user input and write it to a text field on the layout?  I have seen some discussions around a simple popup to notify that an email has been sent, but was curious if anyone has implemented something like a comment popup that would write the results to a text field.

 

The use case here is handling a record that is enrolled in an advanced workflow that is pending a user action (approve/reject).  We have a requirement for the user to provide comments whenever the action is a rejection.  Today, we are somewhat limited in our options on how to meet this requirement:

  1. Allow the user to click on the Reject button and move the workflow to another user action node where the rejection comment field is required.  Once the rejection comment has been entered into the text area field, the user would click on another workflow button to complete the rejection.
  2. Provide a required comment box at the top of the record where the user can enter their comment.  This would require comments for any user action (approval or rejection).
  3. Provide a (not required/optional) comment box at the top of the record where the user could enter their comment.

 

We would be looking for a fourth option that would build on #3.  The javascript popup would hijack the onclick event of the button and prompt the user for a rejection comment.  When the user submits the javascript popup, the response would be written to the comment box.

 

Curious to know if this is possible or if someone has done something similar.

6 REPLIES 6

Anonymous
Not applicable

I use a Custom object javascript for that very purpose.   The first step is to intercept the button:

(see Unbind AWF buttons? ).

 

//You need to define the App ID and Field ID

var AppLevelID = <insert application ID here>
var fldID = getFieldIdByName(<field ID here>,AppLevelID);

 

Then you just check the Rejection Comment field to see if it has data in it (under the validation section of code:

function goValidateAll()
{
    var allValid = true;
    var warningtext = "";
    // Check to see if Required Rejection Comments is non-blank.  If not, then display the errors and exit out
    // get all the answers
    var comments = $('input[id*="f' + fldID + 'c"]').val();
            
    // check to see if any required fields are blank
    if(!comments)
    {
        allValid = false;
        //Set pop up message and title variables
        var msg = 'Rejection Comments cannot be blank';
        var title = 'Required Field';
    }
    // not all fields are filled in, so show popup alert
    if(allValid == false)
    {
       WarningAlert(msg,title);
    }    
  
    else
    {
                
    // finally, save the record and transition to the next node
        oldTransitionClick();
    }    
}

Anonymous
Not applicable

And you can easily expand this code to check for different things:

is the value in field1 >= Field2 (Dates, Numeric etc)

I like to compare the dates to enforce no past/future dates as needed.

So it sounds like you use this as a validation check and reminder for the user to provide a comment (if they did not enter one).

Would it be possible popup an input box where the user could actually type in their comment and then write the input to the appropriate field?

Really like this use case as we have had requests to date enforcement for our findings and remediation plans. eg Due Dates must be in the future, and remediation plan due dates must be future dates and be prior to the related finding due date. 

Anonymous
Not applicable

I'm not sure.  I am okay at tweaking code but not necessarily building from scratch.  There are a couple of people in the community that  might be able to answer that question Jason Solar and Ilyan Khen pop to mind.

To add to David Merrick input, I used something like this for getting user comment from the dialog box. Just use comment variable to inject into your text field:

<script>
function inputComment(){
var comment = prompt('Be so kind and enter your comment here, please!', '');

if (comment != null){
alert('Many thanks, your comment is [' + comment + ']');
}
}

Sys.Application.add_load(function() {
$('#master_ondemand_52').prop("onclick", null);
$('#master_ondemand_52').click(function() {
inputComment();
});
});
</script>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Also, do not forget to use proper ID of your button, and initiate click of the AWF button after validation in David's code

 

So, you have to use combination.

 

And here is how to add text to text field:

https://community.rsa.com/message/919331?commentID=919331#comment-919331