• SaiG
  • NEWBIE
  • 145 Points
  • Member since 2014

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 22
    Replies
Hi guys, I'm totally new to salesforce, just started. I need your help in, how can I create new record of custom obejct from visualforce page by clicking on custom button?

So I've one custom object called; 'project' and  other 'mapview' and i got visualforce page attached to mapview object and in that page i have custom button, on that button click i want to create new project record. I've gone through few solutions but couldn't understand. 

So posting here and asking for help.

here is what I'm doing:

<apex:page standardController="MapView__c" wizard="true"  >
    
    <apex:pageBlock >
        <apex:form >
                   <apex:commandButton id="btnCreateProject" action="{!URLFOR($Action.MapView__c.Create_New_Project)}" value="Create a project"/>

        </apex:form>
    </apex:pageBlock>
    
</apex:page>
Hello all!

Novice question here: Trying to write a SOQL query which will compare the OwnerId of the Contact to the OwnerId of the Lookup Relationship Object and return only records where OwnerIds on both objects don't match.

The two objects are: 
1. Contacts (Main Object)
2. Lookup Relationship: Sub Zones (Zone__c) 

The Contacts object contains a field with a lookup relationship to the Sub Zones Object (Zone__c)

Both the Contact and the Sub Zone have an owner. We assign Sub Zones if the owners are both are identical.

How would I write a SOQL Query to find the records where they do not match?
I have a field called SCR Impact Score that is a formual field that is totaled based on the following logic:
SCR = (S_c)*0.5 + (R_c)*0.2 + (B_c)*0.1 + (D_c)*0.1 + (M)*0.1

However, the 5 fields (S), (R), (B), (D) and (M) are setup as picklists with the following potential values 0,1,5,or 10. I think I need to convert these to numbers before the above formula will work but I'm not sure how to do that and incorporate it with the additional math needed.
I'm trying to write a trigger that will fire when an event is marked as Completed (on custom Status field). When this happens I want to update the related Account with a timestamp of when this happened
i.e Event marked completed - Account field Timestamp is set to today

i've tried writing the code for it but have not been able to get beyond the below, any ideas/tips would be appreciated - thanks

code -------------------------

trigger Timestamper on Event (after insert, after update)
{
  List <ID> AccId = New List <ID>();
   
    for (Event e: trigger.new)
    {
     if (e.Meeting_Status__c == 'Completed' && e.WhatId !=null)
         {
          AccId.add(e.WhatId);  
         }
    }

   
    List <Account> accList = [SELECT id, Timestamp__c FROM Account WHERE id in:AccId];
    {
     accList.Timestamp__c = System.today();  
    }
    update accList;
}

i think i am close here but getting an "initial term of field expression must be a concrete SObject" error here??
Hi guys, I'm totally new to salesforce, just started. I need your help in, how can I create new record of custom obejct from visualforce page by clicking on custom button?

So I've one custom object called; 'project' and  other 'mapview' and i got visualforce page attached to mapview object and in that page i have custom button, on that button click i want to create new project record. I've gone through few solutions but couldn't understand. 

So posting here and asking for help.

here is what I'm doing:

<apex:page standardController="MapView__c" wizard="true"  >
    
    <apex:pageBlock >
        <apex:form >
                   <apex:commandButton id="btnCreateProject" action="{!URLFOR($Action.MapView__c.Create_New_Project)}" value="Create a project"/>

        </apex:form>
    </apex:pageBlock>
    
</apex:page>

Hi,

   Based on close date in opportunity I need to create a formula field to identify to which quater and year it belongs to QQYYYY format. 

   Please suggest me how to get this details. 
 

Thanks
Sudhir

I need someone to help me with my logic on sending an auto reponse to external customers when they send an email on an existing Case.

Scenario:
  • Customer Service Agent (CSA) is out of the office
  • A Client sends an email on an already open/existing case that is owned by the CSA who is currently out of the office
I want an email to be sent to the client indicating the CSA working their issue is out of the office and I'm having difficulty with the logic so I'm hoping someone out there has some suggestions or guidence.

Here is my logic
  1. Create a field on the User record, maybe a checkbox they can click when they are going to be out of the office.
  2. Create a similar (hidden) field on the Case record that will be updated via Workflow when the Agent sets the Out of Office field to "True"
  3. Now, a client sends an email on an existing case (open or closed, doesn't matter) and if the Out of Office field is "True", send an email to them.
Am I headed down the right path here or should I take a different approach?  I'm just not sure how to capture the event when a client sends an email on an already existing case.  And of course I also need to make sure I don't create an email loop that ends up crashing the system!

I'm still pondering my thinking and I'm going to start designing this but if anyone can chime in on how I'm thinking, I'd greatly appreciate it.
I see standard buttons 'edit', 'delete', 'clone' twice in a details page. I want to remove the standard buttons that appear in the middle of the page. How can I accomplish this?
The original development of our system was done before my time. We no longer have access to the person who created all work flows and tracking this issue down manually will pose a significant time delay in the launch of our new object layouts. 

 How can I track down the trigger flow error and discover what the missing criteria is? 

..If it helps, this error occured while a 'Lead' is being converted to the new objects (Account, opportunity).

See error message below.  

Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. 
A flow trigger failed to execute the flow with version ID 301i0000000LNHA. 
Contact your administrator for help.: [] (System Code)


Thank you!
Hello all!

Novice question here: Trying to write a SOQL query which will compare the OwnerId of the Contact to the OwnerId of the Lookup Relationship Object and return only records where OwnerIds on both objects don't match.

The two objects are: 
1. Contacts (Main Object)
2. Lookup Relationship: Sub Zones (Zone__c) 

The Contacts object contains a field with a lookup relationship to the Sub Zones Object (Zone__c)

Both the Contact and the Sub Zone have an owner. We assign Sub Zones if the owners are both are identical.

How would I write a SOQL Query to find the records where they do not match?
Hi All,

Is there any app in salesforce to send voice messages ?

Thanks,
Anju
I have a field called SCR Impact Score that is a formual field that is totaled based on the following logic:
SCR = (S_c)*0.5 + (R_c)*0.2 + (B_c)*0.1 + (D_c)*0.1 + (M)*0.1

However, the 5 fields (S), (R), (B), (D) and (M) are setup as picklists with the following potential values 0,1,5,or 10. I think I need to convert these to numbers before the above formula will work but I'm not sure how to do that and incorporate it with the additional math needed.
I am having issues testing the one trigger I have. My problem is that in my test class when I insert a QuoteLineItem or OpportunityLineItem object the Product2Id fields are NULL. Well that's a problem because the trigger I developed uses that as a key between the two fields.
Here's the code for example.
trigger MultTransfer on QuoteLineItem (before insert) {
	//trigger for linking multiplier from OpportunityLineItem to QuoteLineItem
    //public Map<String, QuoteLineItem> quoteMap = new Map<String, QuoteLineItem>();
    public Map<Id, QuoteLineItem> quoteMap = new Map<Id, QuoteLineItem>();
    String quoteID,oppID;
    for(QuoteLineItem qli: Trigger.new){
    	//dumping all the QuoteLineItems into the map, also grabbing their quote ID
        quoteMap.put(qli.Product2Id,qli);
        quoteID=qli.QuoteId;
    }
    //creating a Quote object to find the OpportunityId
    public Quote q =[SELECT OpportunityId FROM Quote WHERE Id=:quoteID];
    oppID=q.OpportunityId;
    public OpportunityLineItem[] oli = [SELECT Product2Id, Multiplier__c, UnitPrice FROM OpportunityLineItem WHERE OpportunityId=:oppID];
    Integer i=0;
    for(i=0;i<oli.size();i++){
        if(quoteMap.containsKey(oli[i].Product2Id)){
        	if(quoteMap.get(oli[i].Product2Id).UnitPrice==oli[i].UnitPrice){//Extra hoop incase multiple quotes with different multipliers
        		quoteMap.get(oli[i].Product2Id).QuoteMultiplier__c=oli[i].Multiplier__c;//setting the new quote multiplier
        		try{
        			update quoteMap.get(oli[i].Product2Id);
        		}catch(Exception e){
        			//You done goofed
        		}
        	}
        }
    }
}
 
@istest(SeeAllData=true)
public class TestMultTransfer{
    static testmethod void test(){
        String opportunityName = 'My Opportunity';
        String standardPriceBookId = '';

        PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];
        standardPriceBookId = pb2Standard.Id;
        
        Opportunity o = new Opportunity(AccountId=null, Name=opportunityName, 
        StageName='Prospecting', CloseDate=Date.today());

        insert o;
        Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :o.Id];
        opp.Name=opportunityName;
        update opp;
        System.assertEquals(opportunityName, opp.Name);

        Product2 p2 = new Product2(Name='Test Product',isActive=true);
        insert p2;
        Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :p2.Id];
        System.assertEquals('Test Product', p2ex.Name);

        PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, UnitPrice=322, isActive=true, Product2=p2, Product2Id=p2.Id);
        insert pbe;
        PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id];
        System.assertEquals(standardPriceBookId, pbeex.Pricebook2Id);

        OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id, 
        	Quantity=1, Opportunity=o, Multiplier__c=0.50, UnitPrice=pbe.UnitPrice, PricebookEntry=pbe);
        insert oli;
        //system.assertEquals(p2.Id,oli.Product2Id);
        OpportunityLineItem oliex = [SELECT PriceBookEntryId FROM OpportunityLineItem WHERE Id = :oli.Id];
        System.assertEquals(pbe.Id, oliex.PriceBookEntryId);
        
        Quote q = new Quote(
        	Name='MyQuote',
        	opportunityid=o.id, 
        	pricebook2id=pb2Standard.Id);
 		insert q;
        
        QuoteLineItem qli = new QuoteLineItem(
        	PricebookEntry=pbe, quoteid=q.id, PricebookEntryId=pbe.Id, 
        	Quantity=oli.Quantity, UnitPrice=oli.UnitPrice, QuoteMultiplier__c=1.00);
        
        insert qli;
        system.assertEquals(p2.Id,qli.Product2Id);
        //System.assertEquals(oli.Multiplier__c, qli.QuoteMultiplier__c);
    }
}

 
Good evening dear community, 
I made this code public with sharing class HelperContactTrigger {
    //static method
    public static List<Opportunity> sendEmail(List<Opportunity> opportunities) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name=:'Sales: New Customer Email'];

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Opportunity con : opportunities){

            //check for Account
            if(con.OpportunityId == null && con.Email != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }

        //send mail
        Messaging.sendEmail(emails);

        return opportunities;
    }
}

and was about to create a proper test class, since its nessecary to make it work in the production, I'm not sure how to call the instance of this class in my tast class, any advices? I'm not sure what it exactly has to look like, I know that I need to call Accounts because that's the object but I need to know how to make it work with the method that I use in my class, its a lil different from what I usually do. Thanks in advance!
Hi,

On  particular Owner have how many of record created by today on "Opportunity" object? That Record count will update to another object of "Service" , How to achive this updatetion Using trigger

NOTE: No relationship "Opportunity" to "Service", this case how to do this?
I have used following code but i'm struggle Kindly give any idea
Code:
============
Public class OpportunityTriggerHandler{

  public void OnbeforeInsert(list<Opportunity> listNewOpps){
  
   List<Opportunity> RecordCount=new List<Opportunity>();
   AggregateResult[] groupedResults;
  
   groupedResults = [SELECT Name FROM Opportunity WHERE id =:UserInfo.getUserId() group by name];
   system.Debug('============'+groupedResults);
  
  }
   public void OnbeforeUpdate(Map<Id,Opportunity> newOppMap,Map<Id,Opportunity> oldOppMap){
  List<Forecast_Agent__c> Orders = New list<Forecast_Agent__c>([Select Total_Sale__c from Forecast_Agent__c where Owner.Name ='Puthuvannam']);

    for(Forecast_Agent__c sale : Orders){}
    { 
      sale.count = Opportunity.Count;
    }
     Update Orders; 
  }
  
 }
 

Thanks.
My goal is to override the standard new quote button so that the expiration date on the quote defaults to today()+30. I don't want to use a workflow to accomplish this since I want the default expiration date to appear before the user saves the quote. I started creating the following visualforce page:

<apex:page standardController="Quote" showHeader="False" action="/0Q0/e?ExpirationDate={!TODAY()+30}
&oppid=006Z0000008JgXv">
</apex:page>

I got stuck because I don't know how to set the oppid to autopopulate with the associated opportunity id. I've just manually entered a static oppid  to test with. Does anyone know how I would modify this code to populate the associated opportunity id automatically? 
hai friends,in my account i have a datetime field its value is      5/30/2014 2:49 PM.
when i queried if in apex it show      Fri May 30 09:19:00 GMT 2014.
i want to disaply date time as standard  value (5/30/2014 2:49 PM) in visual force by getting apex class.(change the date format in apex class only)
for ths i tried like this

<apex:page controller="accountdatetime">
{!a.date_created__c}<br/>
{!myDate}
</apex:page>

public with sharing class accountdatetime {
public account a{get;set;}
public user a1{get;set;}
public String myDate{get;set;}
public String strConvertedDate{get;set;}
public accountdatetime()
{
a=[select date_created__c from account where id='0019000000wD8wU'];
Datetime thisDT =a.date_created__c;
TimeZone tz=UserInfo.getTimeZone();
//myDate = thisDT.format('yyyy-MM-dd HH:mm:ss', 'PST');
//strConvertedDate = GMTDate.format('dd/MM/yyyy hh:mm:ss a', 'PST');
myDate = thisDT.format('MM/dd/yyyy hh:mm a','a.date_created__c' );
system.debug('111111'+a.date_created__c+'2222'+myDate);

}

}
ouput:
Fri May 30 09:19:00 GMT 2014
05/30/2014 09:19 AM can any one please help me to get this by using timezone,format in apes class only 
Hey there,

I have a trigger which runs off a referral__c object. Basically, the way it works is that:

Every referal field within the trigger is a lookup or a Master-detail relationship.

R.Referee__c = lookup to Account being referred
R.Referred_IPC__c = Lookup to service which is a child of Account. (An IPC service must be taken on by referee to make the trigger happen)
R.Referrer__c = Master_detail lookup to Account.

When these three fields are filled the trigger creates two service__c records.

Now all this worked well asides from recursion each time I edited to records (So I edited the extra two statements to the if statement)

I attempted to make it so that the two lookups to service, where filled with the ID's of the two added services, but I failed. When I tested the trigger I received this error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Referral_AddBonusService caused an unexpected exception, contact your administrator: Referral_AddBonusService: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.Referral_AddBonusService: line 33, column 1

Then I tried to change the code a tiny bit (as seen below), it works, except that if there are multiple services, it wont neccessarily add the right one. Please Help me to finish this trigger so that it will insert the two service and update the referal record with the inserted Ids.

My two questions are:

1. Can someone please help me set the last two lookups within the trigger.
2. Help me properly bulkify my code.

The

Thank you so much in advance for your time. Below is my code:

trigger Referral_AddBonusService on Referral__c (After Update, After Insert) {


List <Service__c> SerList = new List <Service__c> ();
List <Referral__c> RefList = new List <Referral__c> ();

    // New Account status record
    
    for (Referral__c R : Trigger.new) {
    
   if (R.Referee__c != null && R.Referred_IPC__c != null && R.Referrer__c != null && R.Referrer_Bonus_Service__c == null && R.Referee_Bonus_Service__c == null) { 

        Service__c Ser1 = new Service__c (); //instantiate the object to put values for future record       
        // now map Service fields to new vehicle object that is being created with this Trigger
        
        Ser1.Account__c = R.Referrer__c; // and so on so forth untill you map all the fields. 
        Ser1.Service_name__c = 'Momentum Support';
        Ser1.Service_Type__c = 'referrer-Free';
     
        
        SerList.add(Ser1);
        
       //Again
       Service__c Ser2 = new Service__c (); 
       
       Ser2.Account__c = R.Referee__c; // and so on so forth untill you map all the fields. 
         Ser2.Service_name__c = 'Momentum Support';
        Ser2.Service_Type__c = 'Referee-Free';
        
        
        SerList.add(Ser2);
        
        R.Referee_Bonus_Service__c = Ser2.Id;
         R.Referrer_Bonus_Service__c = Ser1.id;
         
         RefList.add(R);
        
        
       } 
        
    }
    try {
        insert SerList;
        Update RefList;   
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
 

    
    
}

and 
trigger Referral_AddBonusService on Referral__c (Before Update, Before Insert) {


List <Service__c> SerList = new List <Service__c> ();
List<Service__c> SerIdList = [Select Id, Account__c, CreatedDate  from Service__c ORDER BY CreatedDate ];


    // New Account status record
    
    for (Referral__c R : Trigger.new) {
    
   if (R.Referee__c != null && R.Referred_IPC__c != null && R.Referrer__c != null && R.Referrer_Bonus_Service__c == null && R.Referee_Bonus_Service__c == null) { 

        Service__c Ser1 = new Service__c (); //instantiate the object to put values for future record       
        // now map Service fields to new vehicle object that is being created with this Trigger
        
        Ser1.Account__c = R.Referrer__c; // and so on so forth untill you map all the fields. 
        Ser1.Service_name__c = 'Momentum Support';
        Ser1.Service_Type__c = 'referrer-Free';
     
        
        SerList.add(Ser1);
        
       //Again
       Service__c Ser2 = new Service__c (); 
       
       Ser2.Account__c = R.Referee__c; // and so on so forth untill you map all the fields. 
         Ser2.Service_name__c = 'Momentum Support';
        Ser2.Service_Type__c = 'Referee-Free';
        
        
        SerList.add(Ser2);
        
       } 
        
    }
    try {
        insert SerList;
        
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
    
    for(Referral__c R:trigger.new)
{
for(Service__c S:SerIdList){
        if(S.Account__c == R.Referee__c)
            R.Referee_Bonus_Service__c = S.Id;
if(S.Account__c == R.Referrer__c)
            R.Referrer_Bonus_Service__c = S.Id;

        }

}

}

//oppcountry is List<String>

cnt= [select Id,Name,Opp_Country__c from Mat__c where Opp_Country__c<>''];

for(integer i=0;i<cnt.size();i++){
oppcountry= cnt[i].Opp_Country__c.split(';');
}

can anybody help me in this, I am unable assign country values to oppcountry.
Thanks in advance.
I'm trying to write a trigger that will fire when an event is marked as Completed (on custom Status field). When this happens I want to update the related Account with a timestamp of when this happened
i.e Event marked completed - Account field Timestamp is set to today

i've tried writing the code for it but have not been able to get beyond the below, any ideas/tips would be appreciated - thanks

code -------------------------

trigger Timestamper on Event (after insert, after update)
{
  List <ID> AccId = New List <ID>();
   
    for (Event e: trigger.new)
    {
     if (e.Meeting_Status__c == 'Completed' && e.WhatId !=null)
         {
          AccId.add(e.WhatId);  
         }
    }

   
    List <Account> accList = [SELECT id, Timestamp__c FROM Account WHERE id in:AccId];
    {
     accList.Timestamp__c = System.today();  
    }
    update accList;
}

i think i am close here but getting an "initial term of field expression must be a concrete SObject" error here??
Hello,

I just made this formula and thought it could save someone in the future some time.  Entering this into a formula field will give you the full state name based on abbreviation, just do a simple find and replace for "Field" in excel to edit the formula for your specific need.

if(Field='AL','Alabama',if(Field='AK','Alaska',if(Field='AZ','Arizona',if(Field='AR','Arkansas',if(Field='CA','California',if(Field='CO','Colorado',if(Field='CT','Connecticut',if(Field='DE','Delaware',if(Field='FL','Florida',if(Field='GA','Georgia',if(Field='HI','Hawaii',if(Field='ID','Idaho',if(Field='IL','Illinois',if(Field='IN','Indiana',if(Field='IA','Iowa',if(Field='KS','Kansas',if(Field='KY','Kentucky',if(Field='LA','Louisiana',if(Field='ME','Maine',if(Field='MD','Maryland',if(Field='MA','Massachusetts',if(Field='MI','Michigan',if(Field='MN','Minnesota',if(Field='MS','Mississippi',if(Field='MO','Missouri',if(Field='MT','Montana',if(Field='NE','Nebraska',if(Field='NV','Nevada',if(Field='NH','New Hampshire',if(Field='NJ','New Jersey',if(Field='NM','New Mexico',if(Field='NY','New York',if(Field='NC','North Carolina',if(Field='ND','North Dakota',if(Field='OH','Ohio',if(Field='OK','Oklahoma',if(Field='OR','Oregon',if(Field='PA','Pennsylvania',if(Field='RI','Rhode Island',if(Field='SC','South Carolina',if(Field='SD','South Dakota',if(Field='TN','Tennessee',if(Field='TX','Texas',if(Field='UT','Utah',if(Field='VT','Vermont',if(Field='VA','Virginia',if(Field='WA','Washington',if(Field='WV','West Virginia',if(Field='WI','Wisconsin',if(Field='WY','Wyoming','Other'))))))))))))))))))))))))))))))))))))))))))))))))))

Have a great day!