Encoding Text

 

function encodeViewState(str) {
return escape(str).replace(/\+/g,'%2B').replace(/\*/g, '%2A').replace(/=/g,'%3D').replace(/:/g,'%3A').replace(/;/g,'%3B').replace(/\//g, '%2F');
}

var msg = $context.currentItem.previousItem;
var viewStateValue= msg.getResponse(msg.RESPONSE_HTTP_BODY_AS_HTML, "//*[@name='com.salesforce.visualforce.ViewState']/@value")[0];

// viewStateValue now contains the string that you want -- you can put that into a clip property

viewStateValue=encodeViewState(viewStateValue);

$prop.set("MessageClip", "viewState", viewStateValue);

$context.result.postMessage($context.result.LEVEL_INFO, "viewState: " + viewStateValue);