• rick82000
  • NEWBIE
  • 55 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies

This is the first time I am writing Ajax, but it seems pretty straight forward. However I am getting an error for which I cannot find an answer online.

 

I am trying to put a custom button on a Case Page Layout so when a user clicks the button then it will update the Case Owner to be user. The logic is able to query all the information correctly, but I am unable to update the record.

 

 

{!requireScript("/soap/ajax/19.0/connection.js")}

var CaseObj= new sforce.SObject("Case");

var CaseNum = '{!Case.CaseNumber}'
var UserId = '{!User.Id}';
var CaseId = '{!Case.Id}'
var ExistingOwner = '{!Case.OwnerId}'
var CaseObjs = sforce.connection.query("select id, OwnerId from Case where Id ='{!Case.Id}'");

CaseObj = CaseObjs;

if ( UserId == ExistingOwner) {
alert ('You already own the case');

}
else {

CaseObj.OwnerId = UserId;
CaseObj.Id = '{!Case.Id}';
result = sforce.connection.update([CaseObj]);
alert ('You have accepted Case Number' + CaseNum);

}

alert (CaseId + UserId + ExistingOwner + CaseObj);

 

 

 

This particular line gives me the following error when executed: "A problem with OnClick Javascript for this button was encountered. faultcode: Soapenv: Client, faultstring Missing entity type information. SObject requires a seperate 'type' field be sent"

result = sforce.connection.update([CaseObj]);

I will appreciate any help on this issue.

 

Thank You in advance.

 

Hello,

 

I am trying to roll up a custom amount fields based on the parent/child relationship on the account.

 

For Example: 

 

 

  • There is a Parent Company record, and two Child company records.
  • Each Child Company has 100k in the field (Assets Under Advisement). I would like to sum the Child company Assets Under 
  • Advisement on the parent company. Hence the parent company Assets Under Advisement should be 200k.

 

 

Here is my  Trigger for the same (I need help on how can I complete this trigger without running on Apex Governor limit for too many SOQL Queries. Please note that my trigger is not complete.Of course :smileytongue::)

 

 

trigger RecalculateAssetsUnderAdvicement on Account (after update) {
	Double AssetsTotal =0.0;
	Account[] Originator = Trigger.new;
	Account [] UpdateAcc = new Account[]{};

for (Account Origin : Originator){
for (Account OuterLoop : [select id, Assets_Under_Advicement__c from Account where id =: Origin.ParentId]) {
		for (Account ChildRecords: [select id, Assets_Under_Advicement__c from Account where id =: Origin.ParentId]) {
					AssetsTotal = ChildRecords.Assets_Under_Advicement__c;
				}
				OuterLoop.Assets_Under_Advicement__c = AssetsTotal;
				UpdateAcc.add(OuterLoop);
			}
			update UpdateAcc;
	}
}

 

 

 

trigger RecalculateAssetsUnderAdvicement on Account (after update) {
Double AssetsTotal =0.0;
Account[] Originator = Trigger.new;
for (Account Origin : Originator){
if (Origin.ParentId != null) {
for (Account ChildRecords: [select id, Assets_Under_Advicement__c from Account where id =: Origin.ParentId]) {
AssetsTotal = ChildRecords.Assets_Under_Advicement__c;
}
}
update UpdateAcc;
}
}

Hi All,

 

Is there a step by step tutorial on how to compile APEX code / deploy to server? I see code snippets everywhere, but not quite sure how to apply it to my Salesforce instance?

 

I realliy need the basics mapped out for me (i.e., Open Eclips IDE, Create New  Project, Paste Code Into....etc etc etc) Even a Hello World type example would be extremely helpful!

 

Thank you Salesforce Community.

  • September 01, 2010
  • Like
  • 0

Hi,

 

I have written a trigger and the error is comng at the line it is highlighted

 

The fields here highlighted are the lookup of User object.

 

 

trigger UpdateMarkRequestTrigger on Marketing_Request__c (before update) {
if(Trigger.isBefore){
if(Trigger.isUpdate){
for(Marketing_Request__c mr:Trigger.old){
System.debug(Logginglevel.INFO,mr.Name);
if(mr.Status__c=='Review Completed')
System.debug(Logginglevel.INFO,mr.Status__c);
System.debug(Logginglevel.INFO,mr.Project_Owner__c);
System.debug(Logginglevel.INFO,mr.Reassign_To__c);

mr.Reassign_To__c=mr.Project_Owner__c;

System.debug(Logginglevel.INFO,mr.Project_Owner__c);
System.debug(Logginglevel.INFO,mr.Reassign_To__c);
}
}
}

 

 

Help will be appreciated

 

Regards

 

Praz

  • September 01, 2010
  • Like
  • 0

This is the first time I am writing Ajax, but it seems pretty straight forward. However I am getting an error for which I cannot find an answer online.

 

I am trying to put a custom button on a Case Page Layout so when a user clicks the button then it will update the Case Owner to be user. The logic is able to query all the information correctly, but I am unable to update the record.

 

 

{!requireScript("/soap/ajax/19.0/connection.js")}

var CaseObj= new sforce.SObject("Case");

var CaseNum = '{!Case.CaseNumber}'
var UserId = '{!User.Id}';
var CaseId = '{!Case.Id}'
var ExistingOwner = '{!Case.OwnerId}'
var CaseObjs = sforce.connection.query("select id, OwnerId from Case where Id ='{!Case.Id}'");

CaseObj = CaseObjs;

if ( UserId == ExistingOwner) {
alert ('You already own the case');

}
else {

CaseObj.OwnerId = UserId;
CaseObj.Id = '{!Case.Id}';
result = sforce.connection.update([CaseObj]);
alert ('You have accepted Case Number' + CaseNum);

}

alert (CaseId + UserId + ExistingOwner + CaseObj);

 

 

 

This particular line gives me the following error when executed: "A problem with OnClick Javascript for this button was encountered. faultcode: Soapenv: Client, faultstring Missing entity type information. SObject requires a seperate 'type' field be sent"

result = sforce.connection.update([CaseObj]);

I will appreciate any help on this issue.

 

Thank You in advance.

 

Hello,

 

I am trying to roll up a custom amount fields based on the parent/child relationship on the account.

 

For Example: 

 

 

  • There is a Parent Company record, and two Child company records.
  • Each Child Company has 100k in the field (Assets Under Advisement). I would like to sum the Child company Assets Under 
  • Advisement on the parent company. Hence the parent company Assets Under Advisement should be 200k.

 

 

Here is my  Trigger for the same (I need help on how can I complete this trigger without running on Apex Governor limit for too many SOQL Queries. Please note that my trigger is not complete.Of course :smileytongue::)

 

 

trigger RecalculateAssetsUnderAdvicement on Account (after update) {
	Double AssetsTotal =0.0;
	Account[] Originator = Trigger.new;
	Account [] UpdateAcc = new Account[]{};

for (Account Origin : Originator){
for (Account OuterLoop : [select id, Assets_Under_Advicement__c from Account where id =: Origin.ParentId]) {
		for (Account ChildRecords: [select id, Assets_Under_Advicement__c from Account where id =: Origin.ParentId]) {
					AssetsTotal = ChildRecords.Assets_Under_Advicement__c;
				}
				OuterLoop.Assets_Under_Advicement__c = AssetsTotal;
				UpdateAcc.add(OuterLoop);
			}
			update UpdateAcc;
	}
}

 

 

 

trigger RecalculateAssetsUnderAdvicement on Account (after update) {
Double AssetsTotal =0.0;
Account[] Originator = Trigger.new;
for (Account Origin : Originator){
if (Origin.ParentId != null) {
for (Account ChildRecords: [select id, Assets_Under_Advicement__c from Account where id =: Origin.ParentId]) {
AssetsTotal = ChildRecords.Assets_Under_Advicement__c;
}
}
update UpdateAcc;
}
}