You need to sign in to do that
Don't have an account?
Naomi Harmon
setContentInnerHTML include javascript variable
I have a beautiful button created on my Contact object that shows a popup and uses sforce.connect.query to get an associated Opportunity. Everything is working perfectly, except for me trying to display the Opportunity's name in the popup. How can I access and display my javascript variable "name" from my box.setContentInnerHTML(...) ? Here is my code:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} var records = sforce.connection.query("SELECT Id, Name FROM Opportunity Where Contact__r.Id = '{!Contact.Id}' AND App_Opp_For__c ='Manna' AND IsClosed=false ORDER BY CreatedDate"); var oppRec = records.getArray('records')[0]; var oppId = oppRec.Id; url = `${oppId}`; var oppName = oppRec.Name; var name = `${oppName}`; var box = new SimpleDialog("hersh"+Math.random(), true); parent.box = box; box.setTitle("Manna Application"); box.createDialog(); box.setWidth(350); box.setContentInnerHTML("<p align='center'><img src='https://c.cs21.content.force.com/servlet/servlet.ImageServer?id=015q00000007FVD&oid=00Dq0000000CSTt&lastMod=1521667670000' style='margin:0 5px;'/></p></br><p align='center'>{!Contact.FirstName} already has a Manna Opportunity open.</br></p><p align='center'><br /><button class='btn' onclick='window.parent.box.hide(); window.open(url);'>Go To Opp</button> <button class='btn' onclick='window.parent.box.hide(); window.open(url);'>New Manna App</button></p>"); box.setupDefaultButtons(); box.show();
The concatenation sign for string in Javascript is just the sign "+" (or there is a function concat)
All Answers
The concatenation sign for string in Javascript is just the sign "+" (or there is a function concat)
Did it work?
Big thanks for your feedback.
(that is always valuable to confirm a solution when it is difficult to reproduce exactly the case).
Alain