• Deepak Kumar 138
  • NEWBIE
  • 160 Points
  • Member since 2016
  • Accenture


  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 19
    Replies
I am new to Javascript language. The code in Bold below is triggered by on-click javascript button. It's working fine; however, I was asked to tweak it to only update the records where the lookup field " agreement " is equal to 'Agr3'. We have 3 agreements (Agr1 - Agr2 -  Agr3). Right now, the Javascript button is updating all the records in the "Request__c" object, but I want to be able to have the code filter and ONLY update the records where Request__c.agreement__r.name = 'Agr3'

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Request__c)};
var updateRecords = []; 
if (records[0] == null) { 
alert("Please select at least one record to update."); 
} else { 
for (var a=0; a<records.length; a++) { 
var update_Request__c = new sforce.SObject("Request__c"); 
update_Request__c.Id = records[a]; 
update_Request__c.Due_Date__c = new Date(); 
updateRecords.push(update_Request__c ); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; 
}


I tried using SOQL query to get only the ids for the records that meets the criteria. 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Request__c)}; 
var Agr3Records= sforce.connection.query("SELECT id, Agreement__c  FROM records WHERE Agreement__r.Name = 'Agr3' ");
records = Agr3Records.getArray("records");
for(var i=0; i<records.length; i++)
    {
    var update_Request__c = new sforce.SObject("Request__c"); 
    update_Request__c.Id = records[i]; 
    update_Request__c.Due_Date__c = new Date(); 
    updateRecords.push(update_Request__c ); 
    }
result = sforce.connection.update(updateRecords); 
parent.location.href = url; 
}
Can you please help out. I can't see to figure out the get the code to work without getting errors. Thanks
I am a very experienced developer and just ran into one that I just don't see.  I'm trying to set a boolean variable from a javascript side.  Here is the portion of the code:
// variables correlating to the checkboxes
	Boolean accountb, leadb, opportunityb;
            
	@RemoteAction
    public Null SetCategory(String category , Boolean setv) {
	
		if (category == 'account') {
			accountb = setv;
(the code goes on with other setttings and ends with a close bracket)
The error shows "Compile Error: Variable does not exist: accountb at line 14 column 13".  accountb is just above this.  What am I missing??
 
I need to calculate the sum of tax field of all the quote line items which have taxable check box true and display it on the Quote field.The tax field on the line item is a formula field so i am unable to create a roll up summary.I wrote a trigger but it is failing in delete case.Can somebody guide me where i am goinge wrong with it 
trigger CalculateTotalTax on QuoteLineItem (after insert,after update,after delete) 
{
    list<QuoteLineItem> l;
    if(Trigger.isInsert || Trigger.isUpdate)
    {
    	l =[SELECT Id,QuoteId,Tax__c,Taxable__c FROM QuoteLineItem WHERE ID IN: Trigger.new];
    }
    if(Trigger.isDelete)
    {
        l =[SELECT Id,QuoteId,Tax__c,Taxable__c FROM QuoteLineItem WHERE ID IN: Trigger.old];
    }
    Decimal ttx=0.00;
    String qid;
    for(QuoteLineItem q : l)
    {
        qid=q.QuoteId;
    }
    for(QuoteLineItem f : l)
    {
        if(f.Taxable__c == true)
        {
                ttx+=f.Tax__c;
        }
    }
    Quote q=[SELECT Id,TotalTax__c FROM Quote WHERE Id =: qid];
    q.TotalTax__c=ttx;
    System.debug(ttx);
    update q;
}
I have a custom object US_Resource_Request__c that has a Master Detail relationship to the Opportunity. I would like to show the Products related list on the US_Resource_Request__c. 
I have tried 
<apex:page standardController="US_Resource_Request__c">
<apex:relatedList list="Product2" subject="{US_Resource_Request__c.Opportunityid}"/>
</apex:page>
And am getting the following error "Error: Formula expression is required for attribute subject in <apex:relatedList> in Products_related_list at line 2 column 85"
 
Hi Averyone..

My name is phanindra im new from salesforce

i have attend a last week interview in MNC Company

He asking one senerio in Visual force ?

Senerio is  : input text field and one button(like submit).
                    You enter any value in input text field after click button show as pass or you not enter anything click the button show as fail 

Please give me Reply ASAP: )

Thanks in Advance..
Hey, 

I'm trying to update a checkbox with a button. The script doesn't have any errors, but i'm getting a popup that says "Unexpected token ILLEGAL" 

Any ideas? Here's the script:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var newRecords = []; 
var opp = new sforce.SObject(“Opportunity”); 
opp.id =”{!Opportunity.Id}”; 
opp.Call_Attempt_No_Answer__c=True; 
newRecords.push(opp); 
result = sforce.connection.update(newRecords); 
window.location.reload();


Thanks!
-Mike
I am new to Javascript language. The code in Bold below is triggered by on-click javascript button. It's working fine; however, I was asked to tweak it to only update the records where the lookup field " agreement " is equal to 'Agr3'. We have 3 agreements (Agr1 - Agr2 -  Agr3). Right now, the Javascript button is updating all the records in the "Request__c" object, but I want to be able to have the code filter and ONLY update the records where Request__c.agreement__r.name = 'Agr3'

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Request__c)};
var updateRecords = []; 
if (records[0] == null) { 
alert("Please select at least one record to update."); 
} else { 
for (var a=0; a<records.length; a++) { 
var update_Request__c = new sforce.SObject("Request__c"); 
update_Request__c.Id = records[a]; 
update_Request__c.Due_Date__c = new Date(); 
updateRecords.push(update_Request__c ); 

result = sforce.connection.update(updateRecords); 
parent.location.href = url; 
}


I tried using SOQL query to get only the ids for the records that meets the criteria. 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 
var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Request__c)}; 
var Agr3Records= sforce.connection.query("SELECT id, Agreement__c  FROM records WHERE Agreement__r.Name = 'Agr3' ");
records = Agr3Records.getArray("records");
for(var i=0; i<records.length; i++)
    {
    var update_Request__c = new sforce.SObject("Request__c"); 
    update_Request__c.Id = records[i]; 
    update_Request__c.Due_Date__c = new Date(); 
    updateRecords.push(update_Request__c ); 
    }
result = sforce.connection.update(updateRecords); 
parent.location.href = url; 
}
Can you please help out. I can't see to figure out the get the code to work without getting errors. Thanks
I am a very experienced developer and just ran into one that I just don't see.  I'm trying to set a boolean variable from a javascript side.  Here is the portion of the code:
// variables correlating to the checkboxes
	Boolean accountb, leadb, opportunityb;
            
	@RemoteAction
    public Null SetCategory(String category , Boolean setv) {
	
		if (category == 'account') {
			accountb = setv;
(the code goes on with other setttings and ends with a close bracket)
The error shows "Compile Error: Variable does not exist: accountb at line 14 column 13".  accountb is just above this.  What am I missing??
 
I need to calculate the sum of tax field of all the quote line items which have taxable check box true and display it on the Quote field.The tax field on the line item is a formula field so i am unable to create a roll up summary.I wrote a trigger but it is failing in delete case.Can somebody guide me where i am goinge wrong with it 
trigger CalculateTotalTax on QuoteLineItem (after insert,after update,after delete) 
{
    list<QuoteLineItem> l;
    if(Trigger.isInsert || Trigger.isUpdate)
    {
    	l =[SELECT Id,QuoteId,Tax__c,Taxable__c FROM QuoteLineItem WHERE ID IN: Trigger.new];
    }
    if(Trigger.isDelete)
    {
        l =[SELECT Id,QuoteId,Tax__c,Taxable__c FROM QuoteLineItem WHERE ID IN: Trigger.old];
    }
    Decimal ttx=0.00;
    String qid;
    for(QuoteLineItem q : l)
    {
        qid=q.QuoteId;
    }
    for(QuoteLineItem f : l)
    {
        if(f.Taxable__c == true)
        {
                ttx+=f.Tax__c;
        }
    }
    Quote q=[SELECT Id,TotalTax__c FROM Quote WHERE Id =: qid];
    q.TotalTax__c=ttx;
    System.debug(ttx);
    update q;
}
I have a custom object US_Resource_Request__c that has a Master Detail relationship to the Opportunity. I would like to show the Products related list on the US_Resource_Request__c. 
I have tried 
<apex:page standardController="US_Resource_Request__c">
<apex:relatedList list="Product2" subject="{US_Resource_Request__c.Opportunityid}"/>
</apex:page>
And am getting the following error "Error: Formula expression is required for attribute subject in <apex:relatedList> in Products_related_list at line 2 column 85"
 
I am trying to place a SOQL statement inside a custom label which will be used in Dynamic Query. I need to reference few other custom labels  inside the SOQL but for some reason these custom labels are appearing as a string value. How do I reference a custom label within a custom label?  Ex: Select Id, Name from Product2 where Product_Ref_Key__c NOT IN(System.Label.ProductReferenceKey1, System.Label.ProductReferenceKey2)
Currently we have an object that is on the Contact and Assignment object. When the button is pushed for the object "Early Release Notes" is it possible to have the both Contact and Assignment auto populate regardless of the object it was created on? Currently both fields are "LookUp" fields when we go into "Lookup Filter" the option we want is not available.
Hi Averyone..

My name is phanindra im new from salesforce

i have attend a last week interview in MNC Company

He asking one senerio in Visual force ?

Senerio is  : input text field and one button(like submit).
                    You enter any value in input text field after click button show as pass or you not enter anything click the button show as fail 

Please give me Reply ASAP: )

Thanks in Advance..
I'm trying to display opportunity product names to opportunity custom field. The trigger is working fine but it displays only last record name. eg. If I have 4 products related to opportunity, it display 4th product name and not display the first three. I would like to display each product name with ',' in between. here is my code. Any idea what need to ​be added in order to display all related products name.
Trigger OppProdLine on Opportunity (before update) {

list<opportunity> sl = trigger.new;

list<opportunityLineItem> slnu = new list<opportunityLineItem>([select id ,product2.name, opportunityId from opportunitylineitem where opportunityId =: trigger.new[0].id]);

string productName='';

for(opportunityLineItem opp : slnu){

 productName = opp.product2.name;

}

for(Opportunity opp : trigger.new){

 opp.Opportunity_Prod__c = productName;


}


}
  • May 03, 2016
  • Like
  • 0
<apex:pageBlockSectionItem> may have no more than 2 child components
this error is seen what to do?
Hey, 

I'm trying to update a checkbox with a button. The script doesn't have any errors, but i'm getting a popup that says "Unexpected token ILLEGAL" 

Any ideas? Here's the script:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var newRecords = []; 
var opp = new sforce.SObject(“Opportunity”); 
opp.id =”{!Opportunity.Id}”; 
opp.Call_Attempt_No_Answer__c=True; 
newRecords.push(opp); 
result = sforce.connection.update(newRecords); 
window.location.reload();


Thanks!
-Mike
Hi All,

in the below code i am creating account record which is returning inserted record in list form accountList. now i want to use the account id created in contact record insertion. so please can you let me know how can i use as i want to pass inserted account id to contact  as parameter .
public class AccountTest
    {
    
        public static List<Account> CreateAccount()
            {
            
                List<Account> accountList = new List<Account>();
                
                Account Acc=new Account(Name='Test2');
                accountList.add(acc);  
                insert accountList;
                return accountList;             
            
            }
            
        public static List<Contact> CreateContact(account accid)
            {
                List<Contact> contactList=new List<Contact>();
                Contact con=new Contact(Lastname='Test1',
                AccountId=accid.id);
                contactList.add(con);
                insert contactList;
                return contactList;
                
                
                
            
            }
        
            
    }

Hi everyone,

I really need some help here, I want in the community to have an interface (a vf page) where I will display the informations about each Account and its related Opportunities, the question is how to do this?
And how to have different information depending on the Account connected?
I would be really grateful if you answer me,

Thanks.