• Parth_Sevak
  • NEWBIE
  • 110 Points
  • Member since 2011
  • Salesforce Certified Professional


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 26
    Replies

Visualforce code:

 

<apex:form ><br />
<apex:outputLabel value="Subject" for="Subject"/>:<br />
<apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
<br /><br />
<apex:outputLabel value="Body" for="Body"/>:<br />
<apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/>
<br /><br /><br />
<apex:commandButton id="sendEmail" value="Send Email" action="{!send}" />
</apex:form>

 

Apex Code:

 

public PageReference send() {
// Define the email

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

String[] addresses = new string[]{'richard@supremetechnologies.in'};

Messaging.reserveSingleEmailCapacity(addresses.size());
// Sets the paramaters of the email
email.setSubject( subject );
email.setToAddresses( addresses );
email.setPlainTextBody( body );

// Sends the email
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

return null;
}

 

I just finished writing and testing few triggers in sandbox. How do I move them to production system?

 

I get an error message:

Entity_Is_Locked

 
  • February 23, 2013
  • Like
  • 0

Hi,

 

In my developer account i have created the following user.

 

 User1 - Administrator

 User2 - Standard User (User license - Salesforce).

 

User1 has creted a custom object Test__c and enabled permission set (Availability - True, Access - Read) for User2, so that User2 can view the records in  Test__c.

 

For the standard object Opportunity User1 has created following trigger,

 

trigger employee_id on Opportunity (after insert, after update)
{
    List<AggregateResult> result = [SELECT OwnerId, Sum(Amount)tvalue FROM Opportunity GROUP BY OwnerId];
    List<Test__c> mylist = new List<Test__c>();
    Set<Test__c> myset = new Set<Test__c>();    
    for (Opportunity s : Trigger.new)
     {
        for(AggregateResult ar : result)
        {
            Test__c mytest = new Test__c();
            mytest.User__c = string.valueOf(ar.get('OwnerId'));
            integer v = integer.valueOf(ar.get('tvalue'));
            mytest.Sum_opp__c = v;
            if(myset.add(mytest))
            {
                mylist.add(mytest);
            }
        }
     }
     try
     {
        insert mylist;
     }
     catch (system.Dmlexception e)
     {
        system.debug (e);
     }
}

 

User1 has created Sharing setting for standard object Opportunity and custom object Test__c as private, so that User1 can view all the records and User2 can view only his records as grant access using hierarchies is enabled.

 

But my problem is, when i run the trigger from both the user account, User2 can view the results of User1 in Test__c(custom Object).

But actually User2 cant view the Opportunity records of User1 due to sharing settings(private).

Similarly User2 must not be allowed to view the results of User1 in Test__c.

 

Is there any way to prevent that issue?

 

Regards,

S.Sivakumar

 

Hi,

 

I have a button in Account Object which has a VF page as the content source. In the VF page I only have one action to call a function in the controller.

So on clicking the button, the function in the controller runs and a new custom object record edit page opens with some values as assigned by the controller.

The problem now is that these values are not getting preset when the record edit page shows up. I tried putting some debug statements in the controller and made sure the values are getting preset as expected. But somehow the values are getting changes when the record edit page opens. I am confused here, this functionality was working fine for over a year now and this problem popped up only last week.

I have checked the logs and looked for any possible triggers that is doing this changes. Strangely the values are getting preset and stays that way till the end of the controller fn execution in the first log and right in the beginning of the next log that is in the beginning of the trigger the values change. I cannot  find any other trigger/WF running since nothing is showing up in the log.

Am I missing something? Should I be looking for something more? Please help.

 

Thanks.!

The following challenge does not validate:

Quick Start: Lightning App Builder - Add Quick Actions and Activate the App
Error: One or more of the quick actions were not added to 'Field Sales App' 
https://developer.salesforce.com/trailhead/project/quickstart-app-builder/quickstart-app-builder4

Hello Friends ,

 

I am trying to insert quote line item list but it is giving error.I am not able to understand why i am getting this error.

ublic class CLS_NewQuoteLineItems {
public string surl='';
public string name{get;set;}
public id qid{get;set;}
public boolean b{get;set;}
public boolean b1{get;set;}
public List<WrapperProduct> prodlist ;
public List<WrapperProduct> selectprodlist {get;set;}
public list<product2> plist{get;set;}
public list<product2> plists{get;set;}
public quote q;
public list<Quotelineitem> qlist{get;set;}
public CLS_NewQuoteLineItems(){
b=true;
b1=false;
qlist=new list<Quotelineitem>();
surl = ApexPages.currentPage().getUrl();
if(surl.contains('0Q0'))
{
q=new quote();
qid=ApexPages.currentPage().getParameters().get('id');
q=[select name from quote where id=:qid];
name=q.name;
}
plist=new list<product2>();
prodlist=new List<WrapperProduct>();
selectprodlist=new List<WrapperProduct>();
plist=[select name,ProductCode ,Family,Description from product2];
system.debug('ppppppppppppp'+plist);

 

}
public List<WrapperProduct> getprodlist () {

integer i = 0;


for(product2 p: plist)
{


WrapperProduct lw = new WrapperProduct(p);
prodlist.add(lw);
i++;
}
system.debug('222222222222'+prodlist);
return prodlist;


}

public pageReference selectproduct()
{
b=false;
b1=true;
plists=new list<product2>();
for (WrapperProduct wp : prodlist)
{
if (wp.checked)
{
plists.add(wp.pro);
selectprodlist.add(wp);
}
}

System.debug('@@@@@@@@@@@@'+ selectprodlist);
return null;
}

public pageReference CancelRec()
{

pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}
public pageReference insertQuoteItem()
{

for(product2 p:plists)
{
Quotelineitem q=new Quotelineitem();
q.pricebookentry.product2id='01tA0000003IUkaIAG';//Here i am getting error.
q.QuoteId=qid;
q.Quantity=1;
q.Description='test';
qlist.add(q);

}
System.debug('uuuuuuuuuuuuuuu'+ qlist);
insert qlist;
pagereference pr = new pagereference('/apex/VF_QuoteDetailPage?id='+qid);
return pr;
}

public class WrapperProduct
{
public boolean checked {get;set;}
public string productName{get;set;}
public string productcode{get;set;}
public Decimal listprice{get;set;}
public string productdescription{get;set;}
public string productfamily{get;set;}
public id prodid{get;set;}
public product2 pro{get;set;}

public WrapperProduct()
{
checked = false;

}

public WrapperProduct(product2 p)
{
pro=p;
prodid=p.id;
productName =p.name;
productcode=p.ProductCode;
productdescription=p.Description;
productfamily = p.Family;
}
}
}

 

Urgent reply will be helpfull.

 

Thanks

  • February 26, 2013
  • Like
  • 0

Hi All,

 

If opportunity stage should to close user have to upload a doc for this i wrote a trigger its working good, now issue is if that attachment is deleted ,opportunity stage should be old value what i have to do how i can wrote trigger on notes and attachment help me

  • February 26, 2013
  • Like
  • 0

I know normally it is not possible but I need to run an after trigger and then update a field. Is there a way to do it?

Visualforce code:

 

<apex:form ><br />
<apex:outputLabel value="Subject" for="Subject"/>:<br />
<apex:inputText value="{!subject}" id="Subject" maxlength="80"/>
<br /><br />
<apex:outputLabel value="Body" for="Body"/>:<br />
<apex:inputTextarea value="{!body}" id="Body" rows="10" cols="80"/>
<br /><br /><br />
<apex:commandButton id="sendEmail" value="Send Email" action="{!send}" />
</apex:form>

 

Apex Code:

 

public PageReference send() {
// Define the email

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

String[] addresses = new string[]{'richard@supremetechnologies.in'};

Messaging.reserveSingleEmailCapacity(addresses.size());
// Sets the paramaters of the email
email.setSubject( subject );
email.setToAddresses( addresses );
email.setPlainTextBody( body );

// Sends the email
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

return null;
}

 

I just finished writing and testing few triggers in sandbox. How do I move them to production system?

 

I get an error message:

Entity_Is_Locked

 
  • February 23, 2013
  • Like
  • 0

Hello,

I have a master object- Parentobj1

Detail child obj-childobj1 in a master detail relationship

 

When i create a NEW Record using the the NEW button in the  Parentobj1,i want to add the childobj1 fields in the EDIT page of the 

Parentobj1 ,itself

 

Currently the process  is to create the parentobj1 record using the NEW button  and Save It and then NAVIGATE to the child Related list click new enter and save it,

 

I know a a VF page can accomplish it but i want a simple solution.

any thoughts?

 

  • February 22, 2013
  • Like
  • 0

Hello,

 

I have created the trigger below.  It saves fine and runs without errors, but it does not do anything.  It's meant to trigger when an Opportunity Product is added, edited, or deleted.  It looks at some criteria on the Product (i.e., Product_Group__c, Product_Family__c, and ProductCode) and then checks or unchecks 3 custom fields on the associated Opportunity (Product__c, Service__c, 3rdParty__c) based on whether or not products have been chosen that meet the criteria.  However, as I mentioned, the trigger does not seem to do anything when the products are added or edited.  Is there something I am missing or something I did not do correctly?  Thanks for any help!

 

trigger FieldUpdates1 on OpportunityLineItem (before insert, before update, before delete)
{
//Update Opportunity section fields based on product(s) chosen

Map<Id,Opportunity> Opp1 = new Map<Id,Opportunity>();
set<Id> Ids = new Set <Id>();

FOR(OpportunityLineItem OppLine1 :trigger.new) {
Ids.add(OppLine1.OpportunityId);
}

Map<id,Opportunity> Opp2 = New Map<id,Opportunity>([SELECT Id, Product__c,Service__c,3rdParty__c
FROM Opportunity
WHERE Id IN :Ids]);

for(OpportunityLineItem OppLine2 : trigger.new)
{
Opportunity Opp2a = Opp2.get(OppLine2.OpportunityId);

if((OppLine2.Product_Group__c == 'Product') && (OppLine2.Product_Family__c == 'Group 1')){
Opp2a.Product__c = true;
}
else {
Opp2a.Product__c = FALSE;
}

if((OppLine2.Product_Group__c == 'Service') && (OppLine2.PricebookEntry.Product2.ProductCode == 'GROUP_2')){
Opp2a.Service__c = TRUE;
}
else {
Opp2a.Service__c = FALSE;
}

if((OppLine2.Product_Group__c == '3rdParty') && (OppLine2.PricebookEntry.Product2.ProductCode == 'GROUP_2')){
Opp2a.3rdParty__c = TRUE;
}
else {
Opp2a.3rdParty__c = FALSE;
}

Opp1.put(Opp2a.id,Opp2a);
}

Update Opp1.Values();
}

  • February 22, 2013
  • Like
  • 0

Hi,

 

can you tell me, how to disable the standard CreatePDF button on quote view page based on status picklist value.

 

CreatePDF button should be enable only when that status is  "Approved " or "Accepted"

 

Thanks in Advance

Karthik

HI,

I have a pageblocktable and I have account records, When I try to hover on account, The detail page is rendering according to account.What I want is when I make onmouseout, I want the detail page to be removed.

My code is---
<apex:form >

<apex:pageBlock title="Account">

<apex:pageblockSection title="List Of Accounts">

<apex:pageBlockTable value="{!accounts}" var="acct" rows="5">


<apex:column headerValue="Account Names" >

{!acct.name}

<apex:actionSupport event="onmouseover" status="act" reRender="op" >

<apex:param name="aid" value="{!acct.id}" />

</apex:actionSupport>
</apex:column>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock></apex:form> 
<apex:actionStatus startText="Please Wait ...Loading.........." id="act"/>
<apex:outputPanel id="op">
<apex:detail subject="{!$CurrentPage.parameters.aid}" relatedList="true" />
<apex:relatedList list="Called_On_By__r"/>
</apex:outputPanel>

  • February 22, 2013
  • Like
  • 0

Hi,

 

In my developer account i have created the following user.

 

 User1 - Administrator

 User2 - Standard User (User license - Salesforce).

 

User1 has creted a custom object Test__c and enabled permission set (Availability - True, Access - Read) for User2, so that User2 can view the records in  Test__c.

 

For the standard object Opportunity User1 has created following trigger,

 

trigger employee_id on Opportunity (after insert, after update)
{
    List<AggregateResult> result = [SELECT OwnerId, Sum(Amount)tvalue FROM Opportunity GROUP BY OwnerId];
    List<Test__c> mylist = new List<Test__c>();
    Set<Test__c> myset = new Set<Test__c>();    
    for (Opportunity s : Trigger.new)
     {
        for(AggregateResult ar : result)
        {
            Test__c mytest = new Test__c();
            mytest.User__c = string.valueOf(ar.get('OwnerId'));
            integer v = integer.valueOf(ar.get('tvalue'));
            mytest.Sum_opp__c = v;
            if(myset.add(mytest))
            {
                mylist.add(mytest);
            }
        }
     }
     try
     {
        insert mylist;
     }
     catch (system.Dmlexception e)
     {
        system.debug (e);
     }
}

 

User1 has created Sharing setting for standard object Opportunity and custom object Test__c as private, so that User1 can view all the records and User2 can view only his records as grant access using hierarchies is enabled.

 

But my problem is, when i run the trigger from both the user account, User2 can view the results of User1 in Test__c(custom Object).

But actually User2 cant view the Opportunity records of User1 due to sharing settings(private).

Similarly User2 must not be allowed to view the results of User1 in Test__c.

 

Is there any way to prevent that issue?

 

Regards,

S.Sivakumar

 

Hi all of u , am newly involved in sfdc Automation Testing project. plz guide me any documentation regarding Automation testing.

Hi,

 

I have a button in Account Object which has a VF page as the content source. In the VF page I only have one action to call a function in the controller.

So on clicking the button, the function in the controller runs and a new custom object record edit page opens with some values as assigned by the controller.

The problem now is that these values are not getting preset when the record edit page shows up. I tried putting some debug statements in the controller and made sure the values are getting preset as expected. But somehow the values are getting changes when the record edit page opens. I am confused here, this functionality was working fine for over a year now and this problem popped up only last week.

I have checked the logs and looked for any possible triggers that is doing this changes. Strangely the values are getting preset and stays that way till the end of the controller fn execution in the first log and right in the beginning of the next log that is in the beginning of the trigger the values change. I cannot  find any other trigger/WF running since nothing is showing up in the log.

Am I missing something? Should I be looking for something more? Please help.

 

Thanks.!

I'm trying to use this method in a dynamic SOQL query. Follow the sample code:

 

public static String getRowById(String sobjName, id id){
	String query = 'select ';            
	Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(sobjName).getDescribe().fields.getMap();
	for(String f : objectFields.keySet()){
		query += f;
		query += ',';
	}
	
	query = query.substring(0,query.length()-1);
	query += ' from '+ sobjName;
	query += ' where id = \'' + String.escapeSingleQuotes(id) + '\'';
	query += ' limit 1';
	
	return query;
}

 

The problem is that this is still considered as a SOQL Injection vulnerability.

Am I missing something here? I also tried to use it as a parameter like this:

 

getRowById('SFT_Brand__c',String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('id')));