Your merge field needs to be quoted and escaped:
var rec = {!Apttus__APTS_Agreement__c.Reason_for_cancelation__c};
just dumps the value of the field directly into the JavaScript, likely producing syntax errors. It should be
var rec = '{! JSENCODE(TEXT(Apttus__APTS_Agreement__c.Reason_for_cancelation__c)) }';
JSENCODE()
escapes backslashes for you.
The HYPERLINK()
and IMAGE()
functions are not defined outside of a merge field context {! }
, but aren't meaningful here in a JavaScript button anyway. It's not clear what you're aiming to do; if you wish to do a redirect, do it via JavaScript rather than attempting to use a merge function. If you're aiming to generate content to insert in the page, you may want a formula field or an embedded Visualforce page.