function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Irish@accIrish@acc 

need help on this

I have a situation like...I need to create a cusstom button on parent object and whenevr this button is clicked it should go to the child object and check some fields  and then update the field in parent object based on some condition.plz help me on this

MagulanDuraipandianMagulanDuraipandian

http://infallibletechie.blogspot.in/2013/01/apex-in-ajax.html

 

Check this...

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution and give Kudos.

Anup JadhavAnup Jadhav

A quick solution would be to redirect the user to a visualforce page whose related controller does all the actions that you want to perform, and then redirects the user back to the parent object record page.

 

Does that make sense?

 

Anup

Vinit_KumarVinit_Kumar

You can create a custom Button on Parent Object(Here,it is Account).I am updating Account field Primary_Contact__c if there is related Task with Status ='In Progress'

 

Display Tpe :- Detail Page button

Behavior: Execute Javascript

 

{!REQUIRESCRIPT ("../soap/ajax/19.0/connection.js")}
var accIds = '{!Account.Id}';
result = sforce.connection.query("Select Id,WhatId from Task where Status='In Progress' and WhatId='"+accIds +"'");
  records = result.getArray("records");
 var i = records.length;
if(i>0){
var c = new sforce.SObject("Account");
c.id = accIds ;
c.Primary_Contact__c = "Completed";
result = sforce.connection.update([c]);
if (result[0].getBoolean("success")) {
  
  }
}

parent.location.href = parent.location.href;

Irish@accIrish@acc
Thanks for the reply..