• DeLi
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I have a couple of custom objects related to each other. I created a custom button on the master object which runs an aggregate query:

var gc = new sforce.SObject("Goal_Calculator__c");
gc.Id = '{!Goal_Calculator__c.Id}';
var myQ = "SELECT Goal_Calculator__c, SUM(Jan_Rev__c) FROM Goal_Calculator_Account__c WHERE Goal_Calculator__c = '" + '{!Goal_Calculator__c.Id}' + "' AND Business_Type__c = 'Existing' GROUP BY Goal_Calculator__c";
var myresult = sforce.connection.query(myQ);
gc.Jan_Exist_Bus__c = myresult.records.expr0;
sforce.connection.update([gc]);
window.location.reload();

I than created a visualforce page for the master object (Goal Calculator).
My question is how can I expose/use my custom button on this visualforce page, or how do I implement the same functionality in the visualforce page?

Thank you
 
  • December 28, 2015
  • Like
  • 0
On a custom object, I have created a simple javascript button which creates tasks on the click.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var t = new sforce.SObject("Task");

t.OwnerId = '{!Custome_Object.User_Id}';
t.Subject = "Task With Jscript";
...
t.What = '{!Custome_Object.Id}'; 

var result = sforce.connection.create([t]);

if(result[0].getBoolean("success")){
window.location = "/" + result[0].id;
}else{
alert('Could not create record '+result);
}

I can't figure out how to set the t.What (Related To) field. I get the following error:

{errors:{message:'The external foreign key reference does not reference a valid entity: What', statusCode:'INVALID_FIELD', }, id:null, success:'false', }

My searches tuned out nothing. :(
Any suggestion would be appreciated.

btw, I don't want to use the URL hack or the URLFOR function.

Thank you
  • March 30, 2014
  • Like
  • 0
I have a couple of custom objects related to each other. I created a custom button on the master object which runs an aggregate query:

var gc = new sforce.SObject("Goal_Calculator__c");
gc.Id = '{!Goal_Calculator__c.Id}';
var myQ = "SELECT Goal_Calculator__c, SUM(Jan_Rev__c) FROM Goal_Calculator_Account__c WHERE Goal_Calculator__c = '" + '{!Goal_Calculator__c.Id}' + "' AND Business_Type__c = 'Existing' GROUP BY Goal_Calculator__c";
var myresult = sforce.connection.query(myQ);
gc.Jan_Exist_Bus__c = myresult.records.expr0;
sforce.connection.update([gc]);
window.location.reload();

I than created a visualforce page for the master object (Goal Calculator).
My question is how can I expose/use my custom button on this visualforce page, or how do I implement the same functionality in the visualforce page?

Thank you
 
  • December 28, 2015
  • Like
  • 0
On a custom object, I have created a simple javascript button which creates tasks on the click.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var t = new sforce.SObject("Task");

t.OwnerId = '{!Custome_Object.User_Id}';
t.Subject = "Task With Jscript";
...
t.What = '{!Custome_Object.Id}'; 

var result = sforce.connection.create([t]);

if(result[0].getBoolean("success")){
window.location = "/" + result[0].id;
}else{
alert('Could not create record '+result);
}

I can't figure out how to set the t.What (Related To) field. I get the following error:

{errors:{message:'The external foreign key reference does not reference a valid entity: What', statusCode:'INVALID_FIELD', }, id:null, success:'false', }

My searches tuned out nothing. :(
Any suggestion would be appreciated.

btw, I don't want to use the URL hack or the URLFOR function.

Thank you
  • March 30, 2014
  • Like
  • 0