• RAM Anisetti
  • SMARTIE
  • 883 Points
  • Member since 2015
  • Mr.

  • Chatter
    Feed
  • 29
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 144
    Replies
In my current senarion

I want to trigger for   copying custom field    
accountspecification__c   value to another standard field  SicDesc   

in a same object (Account)  

Please help me.

Thanks In Advance
Hi,
Below is my Rest Resource code to search  Opportunities based on particlar Stage Name. But, when I tried to search in Workbench, I am getting the below error. Actually for any url, the error is same.  Pls let me know, what is the issue with my code.

User-added image
User-added image

Below is my code :
@RestResource(urlMapping = '/Opp/Search/*')
global with sharing class SearchOppty{
    @HttpGet
    global static opp_Wrap searchopp(){
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        opp_Wrap response = new opp_Wrap();
        String text = req.requestURI.Substring(req.requestURI.lastIndexof('/')+1);
        if(doSearch(text))
        SearchOppByStageName(req,res,response);
        return response;
}
public static Boolean doSearch(String text){
    if(text == 'StageName')
        return true;
    else
        return false;
}
public static void SearchOppByStageName(RestRequest req, RestResponse res, Opp_Wrap response){
    String finaltxt = req.params.get('StageName');
    if(finaltxt == null && finaltxt == ''){
        response.Status = 'Error';
        response.Message ='Enter in correct format';
    }
    else{
        List<Opportunity> opps = [select Name, CloseDate, Amount, StageName from Opportunity
                    where StageName =:finaltxt];
        if(opps!= null && opps.size()>0){
            response.opp = opps;
            response.Status = 'Success';
            response.Message = opps.size() + ' Opportunity';
        }
        else{
            response.opp = null;
            response.Status = 'Error';
            response.Message = opps.size() + ' Opportunity';    
        }
    }
}
global class opp_Wrap{
   public List<Opportunity>opp;
    public String Status;
    public String Message;
  public opp_Wrap(){}
}   
}
Hi All,
          I want to send an email notification when account owner is changed. And also i want to send email notification to both old account owner and new account owner which has been changed. How to achieve this. Can anyone send me the code?
I am new to SFDC. I have created a queue (Open Lead) in Admin User and assigned that queue to another user(XYZ).
I created a Lead Assignment rule  with criteria as below-
(Lead: Lead SourceEQUALSWeb) AND (Lead: Lead StatusEQUALSOpen - Not Contacted).

Now I created few lead records which met the above criteria. Then I log in to account of user -XYZ and open the Queue here but I am not able to see those leads in queue (in XYZ account)

Can someone help me to understand the practical approcah of Queue witha bove scenario.


 
Class : Standard stuff from salesforce

@isTest
private class AnimalsCalloutsTest {

    @isTest static  void testGetCallout() {
        // Create the mock response based on a static resource
        StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
        mock.setStaticResource('GetAnimalResource');
        mock.setStatusCode(200);
        mock.setHeader('Content-Type', 'application/json;charset=UTF-8');
        // Associate the callout with a mock response
        Test.setMock(HttpCalloutMock.class, mock);
        // Call method to test
        HttpResponse result = AnimalsCallouts.makeGetCallout();
        // Verify mock response is not null
        System.assertNotEquals(null,result,
            'The callout returned a null response.');
        // Verify status code
        System.assertEquals(200,result.getStatusCode(),
          'The status code is not 200.');
        // Verify content type   
        System.assertEquals('application/json;charset=UTF-8',
          result.getHeader('Content-Type'),
          'The content type value is not expected.');  
        // Verify the array contains 3 items     
        Map<String, Object> results = (Map<String, Object>) 
            JSON.deserializeUntyped(result.getBody());
        List<Object> animals = (List<Object>) results.get('animals');
        System.assertEquals(3, animals.size(),
          'The array should only contain 3 items.');          
    }   

}

While saving getting 

Error: Compile Error: Method does not exist or incorrect signature: [StaticResourceCalloutMock].setStaticResource(String) at line 7 column 9
Hello All,

I'm trying to create a test call on Apex Trigger.  Kindly help on this test class.

APEX Trigger:
trigger CallDate on Task (after insert, after update, after delete) 
{
    Set<Id> con_set = new Set<Id>();
    List<Contact> con_list = new List<Contact>();
    for( Task T: Trigger.new )
    {
        if(String.valueof(T.whoid).startsWith('003') && T.Status=='Completed' && T.Subject=='Call' )
        {
            con_set.add(T.whoid);
        }
    }
     
     for(AggregateResult aggregateResult:[SELECT max(createdDate)MaxCDate,whoid FROM Task WHERE whoid IN: con_set AND Status ='Completed' AND Subject ='Call' Group By whoid])
     {
        con_list.add(new Contact(Id=(id)aggregateResult.get('whoid'),Last_Call__c=date.valueof(aggregateResult.get('MaxCDate'))));
     }
     
    try
    {
     
         if(con_list !=null && con_list.size()>0)
         {
             update con_list;
         }
     
    }Catch(Exception e){
         system.debug('Exception ***'+e.getMessage());
      
     }

}


TEST CLASS:
@IsTest()
public class CallDateTest
{
  static testMethod void MyUnitTest()
  {
  
       list<id> con_set = new list<Id>();
       List<contact> con_list = new List<contact>();
       for( Task T: Trigger.new )
       insert con_set;
       
       Task t = new Task(Priority = 'Normal', whoId = task.id, Subject = 'Call', Status = 'Not Started', Call_Result__c = 'Reached');
       insert t;       
       
       try
       {
       insert t;

       }catch (Exception ee)
       {
       }
       
       
}
}


I'm getting a *"Compile Error: DML requires SObject or SObject list type: List<Id> at line 10 column 8"*   Where am I doing this incorrectly?

Thanks 
hi all

here's a trigger and unit test, the trigger is fine BUT the unit test fails, please help:
 
trigger evtask on event (after update){ 
    {

List<Task> insertTask = new List<Task>();

 

for(event ev : Trigger.new)

{
event oldev = trigger.oldmap.get(ev.id);

    if((oldev.subject !='Book Market Appraisal' ) &&    ev.subject == 'Book Market Appraisal' ){

Task newTask = new Task();

newTask.Subject = 'Market appraisal follow up';

newTask.whatId = ev.whatId;

newTask.status = 'Not Started';

newTask.Priority = 'High';

newTask.Description = 'Please call back the contact to check how the Market Appraisal was';

newTask.ownerid = ev.ownerid;

newTask.whoid = ev.whoid;

newTask.isreminderset = true;

newTask.Reminderdatetime = ev.LastModifiedDate  + 0.0833;



insertTask.add(newTask);

}

if(insertTask.size() > 0)

insert insertTask;

}
}
}
 
@istest
public class testevtask{
static testmethod void testtask() {
event ev=new event();
ev.subject = 'Book Market Appraisal';
ev.ownerid = 'iain banks'
ev.startdatetime = datetime.newInstanceGmt(2015, 1, 1, 1, 1, 1);
ev.enddatetime = datetime.newInstanceGmt(2015, 1, 1, 2, 2, 2);

insert ev;

}
}

 
i have only been able to get 39% code coverage on this trigger need some help with the unit test: 
 
trigger newoppty on contact (after insert, after update) {

     
    
    list<opportunity> opplist = new list<opportunity>();
    
    for (contact con : trigger.new) {
    
    

        if( con.Stage__c == 'Lead' && con.contacttype__C =='Seller') {
            opportunity newopp = new opportunity ();
            
            newopp.ownerid = con.allocated_user__c;
            newopp.name = 'Market Appraisal'; 
            newopp.accountid = con.accountid;
            newopp.CurrencyIsoCode = con.currencyisocode;
            newopp.stagename = 'Lead';
            newopp.recordtypeid = '012250000000Jev';
            newopp.contact__c = con.id;
            newopp.closedate = Date.today().addDays(7);
            newopp.PriceBook2Id = '01s250000005Du6';
            
            

            opplist.add(newopp);

}
}


        try {
        insert opplist;
       OpportunityLineItem[] lines = new OpportunityLineItem[0];
PricebookEntry[] entry = [SELECT Id, Name, UnitPrice FROM PricebookEntry WHERE Pricebook2Id = '01s250000005Du6' AND name In ('Market Appraisal')];
for(Opportunity record: opplist) {
    for (PricebookEntry thisentry : entry)
        lines.add(new OpportunityLineItem(PricebookEntryId=thisentry.Id, OpportunityId=record.Id, UnitPrice=thisentry.UnitPrice, Quantity=1));
}
        insert lines;     
} catch (system.dmlexception e) {
system.debug (e);
}

    
    }

 
Hello,

I get below error when executing trigger
System.AsyncException: Future method cannot be called from a future or batch method:
My code is something like below:
trigger triggername on custom__c (after update, after insert) {

                Call.calculate('abc');	

    
}

global class Call {
    @Future(callout=true)
    Public static void calculate(String value)
    {
       //Do something
    }
}

how will i be able to resolve it, making sure that the the code is exeuted alteast once.
 
  • December 02, 2015
  • Like
  • 0
I have a custom setting:
Country__c  with  checkbox fields called  city__c   and 1 normal field.
now my crietra is to fetch the values inside the custom setting only when  city__c checkbox is checked to true. 
now normally:
 
List<Country__c> country = [Select Name from Country__c where City__c = true ];
List<String> fields = new List<String>();
for(Country__c field : country) {
   fields.add(country.name);
}
System.debug(fields);
This works in workbench but i cannot reproduce the same in apex class. i am not able to do  an soql query with filter condition on the apex class.is there any other alternative???
 
Hello experts

this is my standard page, and the button that I want to appear/disappear is "Crear Factura" depending of
the value of the field "Sucursal__c" which is a picklist
User-added image

If(Sucursal__c=="Maker Centro",true,false)
How can I do this in the standard page?
​any code would be really helpful
 
Hi Team,

Can someone tell me how to identify/rectify if i have two classes one is custom controller and other one is controller extension on what base we can decide its custom controller and controller extension..

Thanks
Vijay S
Here is my Apex Class.  It's a convert button from Proposal Object to Listing Object.
public class ControllerProposalConvertView {
    public Id pId;
    public String convertedAccountId;

    public ControllerProposalConvertView(ApexPages.StandardController stdController){
        pId = ApexPages.CurrentPage().getParameters().get('id');
        System.Debug('#######leadId:' + pId);
    }


    public PageReference convert(){

        try{
        Proposal__c p = [SELECT Id, name, Already_Converted__c, Property__c, Square_Footage__c, Lot_Size__c, Lot__c, Cap_Rate__c, Year_Built__c, Zoning__c, Term__c, Lease_Type__c, NOI__c, Lease_Commencement_Date__c, Rent_Commencement_Date__c, Lease_Expiration_Date__c, Years_Remaining__c, Lease_Notes__c FROM Proposal__c WHERE Id=:pId LIMIT 1];
        
        if (p.Already_Converted__c  =='Not Converted'){
        Listing__c c=new Listing__c(Name=p.Name, Property__c=p.Property__c, Square_Footage__c=p.Square_Footage__c,  Lot_Size__c=p.Lot_Size__c, Lot__c=p.Lot__c, Cap_Rate__c=p.Cap_Rate__c, Year_Built__c=p.Year_Built__c, Zoning__c=p.Zoning__c, Term__c=p.Term__c, Lease_Type__c=p.Lease_Type__c, NOI__c=p.NOI__c, Lease_Commencement_Date__c=p.Lease_Commencement_Date__c, Rent_Commencement_Date__c=p.Rent_Commencement_Date__c, Lease_Expiration_Date__c=p.Lease_Expiration_Date__c, Years_Remaining__c=p.Years_Remaining__c, Lease_Notes__c=p.Lease_Notes__c);
        System.Debug('#######c :' + c );
        insert c;
        p.Already_Converted__c='Converted';
       update p;
        convertedAccountId = c.Id;
        System.Debug('#######convertedAccountId :' + convertedAccountId );
        }
        
        else{
                String sServerName = ApexPages.currentPage().getHeaders().get('Host');
        sServerName = 'https://'+sServerName+'/';
        PageReference retPage = new PageReference(sServerName + '/apex/ProposalConvertView2?id='+ pId); 
        retPage.setRedirect(true);
        System.Debug('#######ALREADYCONVERTED' );
        
        return retPage;
        }
        
        }
        
        catch(Exception e){
            System.Debug('#######Error  - Exception [' + e.getMessage() + ']');
            return null;
        }
        String sServerName = ApexPages.currentPage().getHeaders().get('Host');
        sServerName = 'https://'+sServerName+'/';
        System.Debug('#######sServerName :' + sServerName );
        PageReference retPage = new PageReference(sServerName + convertedAccountId); 
        System.Debug('#######retPage :' + retPage );
        retPage.setRedirect(true);


        return retPage;
    } 
    public PageReference back(){
            String sServerName = ApexPages.currentPage().getHeaders().get('Host');
        sServerName = 'https://'+sServerName+'/';
        System.Debug('#######sServerName :' + sServerName );
        PageReference retPage = new PageReference(sServerName + pId); 
        System.Debug('#######retPage :' + retPage );
        retPage.setRedirect(true);
        
        return retPage;
    }      
}

This is my test class.  What else am I missing? 
@isTest(SeeAllData=true)
public class ControllerProposalConvertViewTest {
    
    static testMethod void convert(){
        Proposal__c p = new Proposal__c (Name = 'Test Name', Already_Converted__c = 'Converted',Property__c = 'a007A000001C6CM',Zoning__c = 'Zone',Lease_Type__c = 'Monthly',Lease_Notes__c = 'Ground Lease',Lot_Size__c = 100.00,Lot__c = 50.00,Cap_Rate__c = 512.75,Year_Built__c = '1975',Term__c = 456,NOI__c = 123.12,Years_Remaining__c = 10.50,Lease_Commencement_Date__c = date.Today(),Rent_Commencement_Date__c = date.Today(),Lease_Expiration_Date__c = date.Today(),Square_Footage__c = 50000);
        PageReference pageRef = Page.ProposalConvertView; 
        Test.setCurrentPage(pageRef); 
        ApexPages.currentPage().getParameters().put('id',p.Id);
        ApexPages.StandardController std = new ApexPages.StandardController(new Proposal__c()); 
        ControllerProposalConvertView cont = new ControllerProposalConvertView (std);
        Id pId;
        cont.convert();
        
        listing__c c = new listing__c (Name = 'Test Name', Already_Converted__c = 'Not Converted',Property__c = 'a007A000001C6CM',Zoning__c = 'Zone',Lease_Type__c = 'Monthly',Lease_Notes__c = 'Ground Lease',Lot_Size__c = 100.00,Lot__c = 50.00,Cap_Rate__c = 512.75,Year_Built__c = '1975',Term__c = 456,NOI__c = 123.12,Years_Remaining__c = 10.50,Lease_Commencement_Date__c = date.Today(),Rent_Commencement_Date__c = date.Today(),Lease_Expiration_Date__c = date.Today(),Square_Footage__c = 50000);
        PageReference retPage = Page.ProposalConvertView2;
        Test.setCurrentPage(retPage); 
        ApexPages.currentPage().getHeaders().get('sServerName');
        cont.back();
        
        
        
        
        }
       }
NOTE:  The ones underlined in my APEX are the ones not being counted or in the developer console is not passing.  Can you advice me what I'm missing?
 
Hi, 

 I wrote a trigger on lead which will fire when lead is converted and opportunity contact gets updated.  trigger is working fine I need to create a test class for deployment
 
trigger updateopportunitycontact on Lead (before update) 
{
for(Lead lead:System.Trigger.new) 
{ 

  if (lead.IsConverted) 
 { 
   Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId];
   Opportunity opp = [SELECT Contact__c from Opportunity where opportunity.id = :lead.ConvertedOpportunityId];
   
   opp.Contact__c = lead.ConvertedContactId;
   
   update opp;
  }
  
}

}

Below is the trigger which i wrote and i dont see any code coverage please suggest me how to make the changes. 
 
@isTest(SeeAllData = true)
private class   auto_lead_assignment {

    public static testmethod void testautolead()
    {
    
test.startTest();

Account A;

  A =  [ select Id,Email_Domain__c,OwnerId,name
                  from Account
                  where  
                  BillingState = 'CA' and 
                  Email_Domain__c = 'walmartlabs.com' limit 1 ];
        
        
    
Lead l = new Lead(lastname='sudhir', company=a.name,Account__c = a.id,run_assn_rules_yn__c = true);
insert l;
 
Lead ld=[Select company from Lead where id = :l.Id];

update ld; 
 
 
  test.stopTest(); 
 
}

}

Thanks
Sudhir


 
I have been trying to find out what's wrong with some apex code. I started seeing compile errors, so I reduced the code to the most basic code to try to find the issue, but I'm not sure what I'm doing wrong here.

Here's the stripped down version of my code:  
 public with sharing class ContactTriggerHandler {

     public static void UpdateOptLogs(List<Contact> newContacts) {

        //Read the new values of the Contact object 
        for (Contact contactObj: newContacts)
        {
            system.debug(' contactObj.Id : ' + contactObj.Id);
        }
    }
}

I get an error : Result: [OPERATION FAILED]: ContactTriggerHandler: Variable does not exist: Id (Line: 6, Column: -1)


Thanks for your help.
 
I need to   attach  or drop pdf from my .net web application to the sales force portal by using SOAP APi or REST Api
for that i guess I need to make a service call between salesforce and my web application , i am new to this .
please let me know where i can get the API or service to drop my pdf files to the salesforce portal.
Hello,

I have below code which changes the record type of "Event" based on record type "Account",
How can i modify it to have it for record type of contacts. I want change the record type of event if it belongs to record types C1, C2, C3.
Id a1 = Schema.SObjectType.Account.getRecordTypeInfosByName().get('X').getRecordTypeId();
Id e1 = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Y').getRecordTypeId();
Id e2 = Schema.SObjectType.Event.getRecordTypeInfosByName().get('Z').getRecordTypeId();

List<Event> eventList = [Select AccountId,RecordTypeId from Event where AccountId != null and RecordTypeId=:e1];

Set<Id> accIds = new Set<Id>();

for(Event evt : eventList){
	accIds.add(evt.AccountId);
}

Map<Id,Account> accMap = new Map<id,account>([Select RecordTypeId from Account]);
integer count = 0;
for(Event evt : eventList){
	if(accMap.containsKey(evt.AccountId)){
		if(accMap.get(evt.AccountId).RecordTypeId == a1){
			evt.RecordTypeId = e2;
			count++;
		}
	}
}

update eventList;

It gives me error for below line when i try for Contact
List<Event> eventList = [Select ContactId,RecordTypeId from Event where ContactId != null];



 
  • September 28, 2015
  • Like
  • 0
Hi,

I am trying to create a trigger to update fields into opportunity object from Recurring Donation object only if the Recurring Donation record exist otherwise it will not take any action. I am new to Apex coding and I saw the "try" and "catch" exception. How can I incorporate these coding for SOQL like "Select ID from npe03_recurring_donation__c where name = 'as defined'".

Thanks for your help.
Philip
Hi, 

I want to write a test class for trigger below below trigger will fire only when opportunity is approved
 
trigger Account_Type_Update on Opportunity (After Update) 
{
    public List<Account> accountsToUpdate = new List<Account>(); 

    for(Opportunity opp : Trigger.New)
    {
        if  ( opp.Is_Approved__c)
        {
            Account acct = new Account(Id = opp.AccountId, Type = 'Client');
            accountsToUpdate.add(acct);
        }
    }

        update accountsToUpdate;
}

I wrote a test class no luck i dont see code coverage is getting improved at all Please suggest me how to make changes. 
 
@isTest
public class   Test_Account_Type_Update {


   static testMethod void testShare() {
   
   List<Account> accs = new List<Account>();
   
   test.startTest();

    Account testAcct = new Account (Name = 'Sudhir Account');
    insert testAcct;
    
      // Creates first opportunity
    Opportunity oppt = new Opportunity(
                            RecordTypeID = '012250000008i5uAAA', 
                            Name ='New mAWS Deal',
                            AccountID = testAcct.ID,
                            StageName = 'Account Opened',
                            Amount = 3000,
                            CloseDate = System.today(),
                            CurrencyIsoCode = 'USD'
                            
                            );

   insert oppt;
    
    
    accs = [SELECT Id,Type FROM Account WHERE ID = :testAcct.ID];
   
   
    for (Account a : accs) {
      a.Type = 'Client';
    }
    update accs;

       
   Test.stopTest();
   
   } 
 

}

Thanks
Sudhir
 
Hai, i tried to insert records through batch apex but it can't ,tell me ,my code is

global class opportunityincrement implements database.batchable<sObject>{
 global database.QueryLocator start(database.batchableContext bc){
  string query='select id,Name,Job_Description__c,Max_Pay__c,Min_Pay__cfrom Position__c';
  return database.getQueryLocator(query);
  }
 global void execute(database.batchableContext bc,list<Position__c>scope){
  system.debug(scope+'bbbbbbbbbbbbbbbbbbb');
 
  list<Position__c> oppty=new list<Position__c>();
   for(Position__c opp:scope){
  
  
   opp.Name='Test';
   opp.Job_Description__c= 'Closed';
   opp.Max_Pay__c= 10000;
    opp.Min_Pay__c= 5000;
   
    oppty.add(opp);
     system.debug(oppty+'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
  
   
   }
    insert oppty;
   }
   global void finish(database.batchableContext bc){
   
   }
  }
Hi Experts,
We have a Custom Button(on click JavaScript Button) on Lead and sending lead information to third party through executing custom soap webservice class .Depends on the result ,we are showing sucess message.
But Lightning Experience is not supported onclick JavaScript Buttons.
Can any one guide us best approach to execute the same functionality in lighting.

My sample click JavaScript Button code is
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 
Var a;

accnt.Id = '{!Lead.Id}';
var r = confirm("you sure want to send it ?");
if(r == true)
{
a = sforce.apex.execute("sendLeadInfo_service", "sendInfo", {
ids: "{!Lead.Id}",
Type: 'Lead'
}, {
onSuccess: refreshList,
onFailure: handleError
});

var refreshList = function(a) {
if(a==true){
alert('success message');

window.location.reload(); 
}
}
var handleError = function() {
alert('Oops! Something went wrong. ');
}
}



 
Hi,

Can any one guide me how to call setDuplicateRuleHeader from PHP using Force.com-Toolkit-for-PHP-master 20.0.I didnt find any method related DuplicateRuleHeader in PHP Tool kit.just i find java sample code in salesforce SOAP guide attached below.i need use similar functionality in php to know how many duplicate leads are there in Salesforce org.

Thanks in Advance
User-added image

 
Hi Experts,
We have a Custom Button(on click JavaScript Button) on Lead and sending lead information to third party through executing custom soap webservice class .Depends on the result ,we are showing sucess message.
But Lightning Experience is not supported onclick JavaScript Buttons.
Can any one guide us best approach to execute the same functionality in lighting.

My sample click JavaScript Button code is
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 
Var a;

accnt.Id = '{!Lead.Id}';
var r = confirm("you sure want to send it ?");
if(r == true)
{
a = sforce.apex.execute("sendLeadInfo_service", "sendInfo", {
ids: "{!Lead.Id}",
Type: 'Lead'
}, {
onSuccess: refreshList,
onFailure: handleError
});

var refreshList = function(a) {
if(a==true){
alert('success message');

window.location.reload(); 
}
}
var handleError = function() {
alert('Oops! Something went wrong. ');
}
}



 
Hi! I am trying to edit some code to copy an email message to case comments based on specific record types. I have two or three record types to add. I have little coding experience so I understand the logic of what I need to do, just not the actual code. I found code for this trigger & class online and it works great as it stands (for all record types). I found additional code for selecting the record type, which it appears to do, but I have no idea how to add additional record types to the query or what to do after the record type is selected. Can someone help me fill in the blanks? The trigger is CopyEmail and the class is CopyEmailCode. Thanks!
 
trigger CopyEmail on EmailMessage (after insert) {
Id recordTypeId = [Select Id From RecordType Where DeveloperName = 'Salesforce_Support'].Id;

/*
How do I add a second and third record type of ‘Salesforce_Projects’ & ‘Salesforce_Training’?
Then, what else goes here to make it only select the requested record types?
*/

    CopyEmailCode.copyEmail(Trigger.new);
}
Thanks so much in advance!
 

Hi All, 

I am hoping you can help me.

This is my Controller, however when i am saving i am getting the the following error message "Error: Compile Error: Invalid field Materials for SObject Materials_Junction__c at line 33 column 17"

i have looked through the relevant examples on wrapper classes however i am a now stuck. 

Really appreciated you help 

public with sharing class testWrapper
{
    public List<Materials__c> Materials {get;set;} 
    public List<materialWrapper> materialWrapperList {get;set;} 
    
    public testWrapper()
    {
        Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10];
        for(Materials__c obj : Materials)
        {
            materialWrapper tempObj= new materialWrapper();
            tempObj.recordId = obj.id;
            tempObj.name = obj.name;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.selectB = false;
            materialWrapperList.add(tempObj);
        }
    }

    //save method
    public void save()
    {
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        
        for(materialWrapper obj : materialWrapperList)
        {
            if(obj.selectB == true)
            {
                Materials_Junction__c temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = '01I20000000rV6V';
                temp.Materials= obj.recordIdId;
                temp.quantity = obj.quantity; 
            }
            recordToInsert.add(obj);
        }
        insert recordToInsert;
    }
    
    
    public class materialWrapper
    {
        public string recordId {get; set;}
        public string name {get; set;}
        public string product {get; set;}
        public string item {get; set;}
        public Decimal quantity {get; set;}
        public boolean selectB {get; set;}
        
        public void materialWrapper()
        {
            recordId = '';
            name = '';
            product = '';
            item = '';
            quantity = 0.0;
            selectB = false;
        }
    }
}

Materials Object API 

Materials Object API

Materials Object Fields 

Materials Object Fields

Materials_Junction API 

Materials Junction Object API

Materials_Junction Fields 
Materials Junction Object Fields
 

Please can anyone tell me the explaination .

If we have trigger on account object, if i insert 1000 records through dataloader how many times the trigger fires?
Hi,

I have a requirement where i have to populate the number of logins made by the users rowwise and show them in  VF page,

                              Profile     August 2016 Logins      July2016logins           June2016Logins
Vivek                     Admin           15                                   15                           11
Rajesh                   Business       10                                   12                           22

I am using LoginHistory object for querying all data's.
Can the month values be populated rowwise?

Thanks
Vivek
Hi,

I want to insert an image when a button is clicked in visualforce page. Here is my code. Can anyone help me to find out what is wrong with the code?

<apex:page >
<script>
function getimage()
{
  <img id="theImage" src="https://upload.wikimedia.org/wikipedia/en/3/34/SFDC_logo.png" width="220" height="55"/>
}
</script>
 <apex:form >
 <apex:commandButton value="Get Image" onclick="getimage()"/>
 </apex:form>
</apex:page>
Hi Team,

Whenever update the Opty fields create a new brand task along with opportunity name. for that we have written a trigger working as expected. But once create a task if we update the description field it should creat a new task not overriding the exting task. 

Every time Step(OptyField) or Description(OptyField) changes, New task should be created

Example: Step = Legal,Description = test 

If I again select Step = Legal and Description = test1234  new task should be created. Currently its updating test to test1234.

Please Find my below trigger and let us know where we made the mistakes.

Trigger Task on Opportunity(after insert,after update){
Set<Id> opIds = new Set<Id>();
List<Task> taskList = new List<Task>();
List<Opportunity> Opps = Trigger.new;
List<Opportunity> taskOps = [Select Id,Steps__c,Description__c from Opportunity where Id in :opIds];
                            
if(Trigger.isInsert){
   for (Opportunity Opp: Opps){
        Task t = new Task();
        t.WhatId = opp.Id;
        t.Subject = 'Help' + ': ' +opp.Steps__c + ': '  + opp.Name; 
        t.Description = opp.Description__c;  
         t.ActivityDate = System.Today()+7;     
        taskList.add(t);
    }
}
//Update 
if(Trigger.isUpdate){
    Map<Id,Opportunity> oldOppMap = Trigger.oldmap;
     for (Opportunity Opp: Opps){
         // description got changed
         if(Opp.Steps__c != oldOppMap.get(opp.Id).Steps__c ){
            Task t = new Task();
            t.WhatId = opp.Id;       
             t.Subject = 'Help' + ': ' +opp.Steps__c + ': '  + opp.Name; 
             t.Description = opp.Description__c;  
             t.ActivityDate = System.Today()+7;
        
            taskList.add(t);
         }
    }
   }
insert taskList;
}

Thanks in Advance
Hi Team,

We have created one related list under Opportunity.We want to display the task completion details in to new related list. Is there any posibility to create a trigger? Please help us.

Thanks in Advance
Hi friends,I am getting an error for a trigger. Condition is: I want to create an product whenever I am creating any opportunity. In opportunity, product is on the based of dependent picklist. Error is -  Error    Error: Compile Error: Entity is not api accessible at line 1 column 1

Code is as below:

trigger CreateProduct on Opportunity (after insert) {
for(Opportunity opp: trigger.new){
Product pod = new Product();
pod.Name = opp.Select_Product__c;

pod.Opportunityid = opp.id;
insert pod;
}
}
  • August 12, 2016
  • Like
  • 0
I didnt get the result of this...can u anyone suggest me...whrere i done a mistake...and i getting error msg like:Method does not exist or incorrect signature: [Contact].size()
Trigger code:
trigger totalcontrigger on Contact (after insert, after update) 
{
    if(trigger.isinsert && trigger.isafter)
    {
        contacthelp.totalcontacts(trigger.new);
    }
}
Class Code:
public class contacthelp {
    public static void totalcontacts(list<contact> conlist){
        Map<id,contact> conmap=new map<id,contact>();
        for(contact c:conlist)
        {
           conmap.put(c.accountid, c) ;
        }
        list<account> acclist=[select id, totalcontacts__c from account where id in:conmap.keyset()];
        for(account a:acclist)
        {
            a.totalcontacts__c=conmap.get(a.id).size();
        }
        update acclist;        
    }
}
I'm trying to delete all Product Line Items for an Opportunity via a javascript button.
This gives me an Unknown error parsing query error in the developer Console
Select OpportunityID From OpportunityLineItem WHERE OpportunityId = '0063300000iu2IC' delete OpportunityID

 
I want to have an Apex code in my managed package with Global Access specifiers on classes, member functions, and member variables. But I want to know, will there be any issue with security review when we release the Managed package on AppExchange.
In my current senarion

I want to trigger for   copying custom field    
accountspecification__c   value to another standard field  SicDesc   

in a same object (Account)  

Please help me.

Thanks In Advance
SOQL query to get account Ids that is associated with a User (a salesforce user)?. Or a SOAP api solution for the same.
I am getting error when trying to "UPSERT" the records from client app(java code) into salesforce using BULK API. Please find the following error " [AsyncApiException  exceptionCode='Invalid Job'  exceptionMessage='External ID was blank for Account. An External ID must be specified for upsert'].Even though after setting the external id field in account object.Please help me in this.
used the below code:
https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_code.htm
We have two Salesforce appexchange product for developers. We need sharp developers on a part-time basis. You will spend 3-4 hours everyday responding to customer requests.

It is okay to have another job.

We are looking for A players. If you are just starting out with Salesforce, please feel free to pass this offer.
Your main task will be:
1. Test our product
2. Respond to customer support requests.

You will not be responsible for development.

We need someone with the following qualities:
1. You are a fast learner.
2. You must have good communication skills.
3. You are great at Salesforce.