+ Start a Discussion

Detail Button Onclick JavaScript

Can somebody please assist with the following query?
I have a custom object called "Meeting_Notes__c" that has an opportunity lookup on the page (not required). I would like to place a detail button that uses the JavaScript Onlick event at the top of the Meeting_Notes__c page.
If an opportunity has been entered I need to open the opprotunity edit page and update the opportunities "Next Step" and "Current Status" fields with data from the active meeting note record.
If there is not an opportunity I would like to alert the user that there is not a related opportunity and return to the active meeting note record.
This is what i have so far.
//establish connection to SF
var connection = sforce.connection;

//Query meeting note and retrieve related Opportunity ID
var meetingnoteId = "{!Meeting_Notes__c.Id}";
var qr = connection.query("Select Meeting_Notes__c.OpportunityId__c From Meeting_Notes__c
Where Meeting_Notes__c = '" + meetingnoteId + "'");
//Declare Opportunity variable
var meetingnoteOpp ="{!Meeting_Notes__c.OpportunityId__c}";
//If an opportunity is populated edit opportunity else alert user that there is not an opportunity
if (meetingnoteOpp != 'NULL')
       alert("This is a test")
Thank you in advance - MLee

var connection = sforce.connection;

var meetingnoteOpp = "{!Meeting_Notes__c.OpportunityId__c}";

if (meetingnoteOpp && meetingnoteOpp != "")
    var opp = new sforce.SObject("Opportunity");
    opp.Id = meetingnoteOpp;
    opp.NextStep = "new value";
    opp.CurrentStatus_Field__c = "new value";
    alert("There is no Opportunity related to this note.");