I'm creating a javascript button on the Quote object that would redirect to a link in another window. I only want to redirect to this other window, if there's a child under the record. For this example: a quote (master) can have multiple services (detail). The object name for services is QService__c.
I want to be able to do an if statement and see if Quote__c (name of the master-detail relationship field on the QService__c object) is not null. As well, I want to pass into the URL the id for the Quote record. Calling the SObject.id - is that the best way to pass that through? Here is what I have so far.
{!REQUIRESCRIPT("/SOAP/ajax/36.0/connection.js")}
var qt = new sforce.SObject("QService__c");
qt.id = "{!QService__c.id}";
if({!QService__c.Quote__c} != null) {
//Open up survey link in new window
window.open("https://services.qualtrics.com/jfe/form/SV_9o7r0gk556N0bGZ/?={!QService__c.id});}
else {
//Catch error
alert("There needs to be a service on this quote."); }