• mandyc
  • NEWBIE
  • 55 Points
  • Member since 2006

  • Chatter
    Feed
  • 2
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 35
    Replies
Hello,

I have a related list that is a visualforce page. I am trying to use a commandlink to delete records from the related list; however, the code is not working. There is no error message displayed. Any assistance is appreciated!

VF page:
<apex:commandlink value="Del" id="customDelete" onClick="return confirmDelete()">
    <apex:param name="delID" value="{!attorney.ID_1__c}" assignTo="{!SelectedId}"/>
</apex:commandlink>

Class:
public void customDelete()
    {
        New List<Att_IP__c> att = [SELECT Id FROM Att_IP__c WHERE Id = :SelectedId];
        if (att.size() > 0){
            Delete att;
        }
    }


Hi All,

I would like to create a VF table dashboard component that includes metrics from a different Salesforce organization. I would like to hear how other people are doing this or how others would propose I do this.

I'm contemplating creating a rest service in the org that I'm looking to pull data from and then calling that from the requesting org. Is this the best approach? Does anyone have an example they can share?

Thanks much!
  • January 28, 2014
  • Like
  • 0
Hello,

I am trying to migrate profiles from one Salesforce environment to another via Eclipse. While attempting to deploy profiles, I am receiving the following error:
-------------------------------------------------------------------------
In field: recordType - no RecordType named Idea.Record_type_for_community_09a500000008b62AAA_entity_Idea found
-------------------------------------------------------------------------

This led me to believe that I first need to deploy the Idea object and it's related settings. When I attempt to deploy the Idea object I receive the below errors:
-------------------------------------------------------------------------
File Name:    objects/Idea.object
   Full Name:  Idea.InternalIdeasIdeaRecordType
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.Record_type_for_community_09a500000008b62AAA_entity_Idea
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.Record_type_for_community_09a500000008b67AAA_entity_Idea
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.Record_type_for_community_09a500000008b6CAAQ_entity_Idea
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.All_WF_Ideas
   Action:  NO ACTION
   Result:  FAILED
   Problem: Could not resolve list view column: IDEA.CATEGORY

   File Name:    objects/Idea.object
   Full Name:  Idea.Ideas_Last_7_Days
   Action:  NO ACTION
   Result:  FAILED
   Problem: Could not resolve list view column: IDEA.IDEA_THEME
-------------------------------------------------------------------------

I see that I cannot create or edit record types on the Ideas object and I don't see communities referenced on the Ideas object anymore. I think they might have been replaced by zones? In Eclipse the zones are stored under a folder called 'Communities' and I was able to deploy them but my errors still remain. Any assistance is appreciated! I hope there is a solution to this otherwise I may be forced to manually recreate all my profiles by hand.

Thanks in advance.
  • January 13, 2014
  • Like
  • 1
Hello,

Every time I delete a record in SF shared by a Salesforce-to-Salesforce connection the publishing organization is notified via email of the deletion. Can this email notification be disabled somehow?

Thank you!
  • January 09, 2014
  • Like
  • 0

Hello,

 

Is there anyway to migrate data from a production Salesforce environment into another and keep the existing record Ids? This would make the migration much easier.

 

Thank you!

  • December 04, 2013
  • Like
  • 0

I am looking to create an exact clone of our production Salesforce instance into a new, completely separate enterprise instance of Salesforce. I would like everything to clone over such as custom objects, fields, triggers, workflows, apex classes, visualforce pages, etc. Has anyone been through a similar situation? I'm looking for all and any advice on the easiest way to complete this task.

 Thank you in advance!!

  • November 11, 2013
  • Like
  • 0

Hello,

 

We are looking to create an exact clone of our production Salesforce instance into a new, completely separate enterprise instance of Salesforce. I would like everything to clone over such as custom objects, fields, triggers, workflows, apex classes, visualforce pages, etc. Has anyone been through a similar situation? I'm looking for all and any advice on the easiest way to complete this task.

 

Thank you in advance!!

  • November 08, 2013
  • Like
  • 0

Hello,

 

The below code was written by someone else and basically it's constructing a URL to a page that downloads a file. Generate() is called by a button click on a VF page. After the button is clicked the user is presented with a white/blank browser page while the file is downloaded. The user then has to click the browser back button to return to the page they clicked the button. I would prefer to have the user stay on the Salesforce page when the button is clicked and have the file download. Any ideas what I might try?

 

The custom button was set to open in a new window and I changed it to display in current window with sidebar. The URL for the button is /apex/ReportParm?Id={!Custom_Reports__c.Id}&Name={!Custom_Reports__c.Name}&URL={!Custom_Reports__c.Report_URL__c}

 

Note, the sidebar does not display when the button is clicked...just a blank, white screen.

 

public class CustomReports_Extension 
{
    Transport__c transport;
    
    string strReportId;
    string strReportName;
    string strURL;
    string strPath;
    integer parmNum;
    string errorMessage;
    
    Report_Parameters__c parms_1;
    Report_Parameters__c parms_2;
    Report_Parameters__c parms_3;
    Report_Parameters__c parms_4;
    Report_Parameters__c parms_5;
    
    List<string> multiPickList_1 = new List<string>();
    List<string> multiPickList_2 = new List<string>();
    List<string> multiPickList_3 = new List<string>();
    List<string> multiPickList_4 = new List<string>();
    List<string> multiPickList_5 = new List<string>();
    
    public CustomReports_Extension(ApexPages.StandardController controller) 
    {
        this.transport = new Transport__c();

        strReportId = System.currentPageReference().getParameters().get('Id'); 
        strReportName = System.currentPageReference().getParameters().get('Name');
        strURL = System.currentPageReference().getParameters().get('URL'); 
        
        List<Report_Parameters__c> parms = new List<Report_Parameters__c>();

        parms = [SELECT Parameter_Label__c, Parameter_Order__c, Name, Render_Text__c, 
                    Render_Date__c, Render_Checkbox__c, Render_Select_List__c, Render_Multi_Select_List__c 
                 FROM Report_Parameters__c WHERE Report_Number__c = :strReportId ORDER BY Parameter_Order__c];

        parmNum = parms.size();
    }
    
    public CustomReports_Extension(Transport__c transporter) 
    {
        this.transport = transporter;
        
        strReportId = System.currentPageReference().getParameters().get('Id');
        strReportName = System.currentPageReference().getParameters().get('Name');
        strURL = System.currentPageReference().getParameters().get('URL'); 
        
        List<Report_Parameters__c> parms = new List<Report_Parameters__c>();

        parms = [SELECT Parameter_Label__c, Parameter_Order__c, Name, Render_Text__c, 
                    Render_Date__c, Render_Checkbox__c, Render_Select_List__c, Render_Multi_Select_List__c  
                 FROM Report_Parameters__c WHERE Report_Number__c = :strReportId ORDER BY Parameter_Order__c];

        parmNum = parms.size();
    }

    public PageReference ParameterCheck()
    {
        string strPath;
        PageReference thisPage;
        
        if (parmNum == 0) //NO PARAMETERS NEEDED
        {
            strPath = strURL;
            thisPage = new PageReference(strPath); 
            thisPage.setRedirect(true);
        }
    
        return thisPage;
    }    

    public pageReference generate()
    {
        string strParmValues = ''; 
        string strParmName = '';
        
        if (parmNum == 0)
        {
            strPath = strURL;
        }
        else
        {
           //PARM 1
           if (parms_1.Render_Text__c == True)
           {
                if (Transport.Name_1_40__c == '' || Transport.Name_1_40__c == ' ')
                {
                    PageReference thisPage = page.ReportParm;
                    thisPage.setRedirect(false);
                    setError();

                    return thisPage;
                }
                else
                {
                    strParmValues = parms_1.Name + '=' + Transport.Name_1_40__c;
                }
           }                   
        }     
        strPath = strURL + '?' + strParmValues;

        PageReference thisPage = new PageReference(strPath);  
        thisPage.setRedirect(true);

        return thisPage;
    }
}

 Thank you.

 

  • October 15, 2013
  • Like
  • 0

Hello,

 

I have a workflow that calls an outbound message (OM) and passes the following values: email, firstname, lastname, id, self_service_password__c.

 

When the OM fires, I receive the following error: MALFORMED_ID: bad id lgQFM4sP. lgQFM4sP is the value in the self_service_password__c field.

 

Here is my code that the OM is calling:

 

        ContactNotification.ContactNotification[] contacts = notifications1.Notification;
        for (int i = 0; i < contacts.Length; i++)
        {
            ContactNotification.ContactNotification notification = contacts[i];
            ContactNotification.Contact contact = (ContactNotification.Contact)notification.sObject;
            
            EnterpriseWebReference.SelfServiceUser ssu = new EnterpriseWebReference.SelfServiceUser();
            ssu.ContactId = contact.Id;
            ssu.FirstName = contact.FirstName;
            ssu.LastName = contact.LastName;
            ssu.Username = contact.Email;
            ssu.Email = contact.Email;
            ssu.TimeZoneSidKey = "America/Chicago";
            ssu.LocaleSidKey = "en_US";
            ssu.LanguageLocaleKey = "en_US";
            ssu.IsActive = true;
            ssu.IsActiveSpecified = true;
            EnterpriseWebReference.SaveResult[] saveResults = binding.create(new EnterpriseWebReference.sObject[] { ssu });
            
            for (int a = 0; a < saveResults.Length; a++)
            {
                EnterpriseWebReference.SetPasswordResult result = binding.setPassword(saveResults[a].id, contact.Self_Service_Password__c);
            }
            
            
        }
        ContactNotification.notificationsResponse response = new ContactNotification.notificationsResponse();
        response.Ack = true;
        return response;

 Any help is appreciated!

Hi All,

 

I'm getting the following error: System.LimitException: Too many SOQL queries: 101. I didn't think my query was inside a loop so I'm unsure how to fix the problem. Your help is greatly appreciated!

 

trigger setContactAndAccountIdOnOrder on Lead (after update) {

    Map<String,Id> Ids = new Map<String,Id>(); 

    for(Lead lead : Trigger.new) {
        if (lead.IsConverted) {
            Ids.put(lead.Person_Id__c,lead.Id);
        }
    } 
    
    List<Order__c> orders = [select Id, Person_Id__c, Contact__c, Account__c from Order__c WHERE Person_Id__c IN :Ids.keySet()];
        for (Order__c o : orders) { 
            Id personId = Ids.get(o.Person_Id__c);
            Lead ld = trigger.newMap.get(personId);
            o.Contact__c = ld.ConvertedContactId;
            o.Account__c = ld.ConvertedAccountId;
        }
        update orders;        
}

 

  • April 25, 2013
  • Like
  • 0

Hello,

 

Can someone help me refactor the below code? If I take out the line return '??'; below then I get the following error:

 

Compile Error: Non-void method might not return a value or might have statement after a return statement. at line

 

I don't understand why I need to return something at line 73 (where I have return '??')

 

Thanks in advance!

 

 

    @HttpPatch
    global static String doPatch() {
    
    RestRequest req = RestContext.request;
    
    // see if a suborder number was part of the uri
    String suborder_no = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    
    if (suborder_no != ''){
        Savepoint sp = Database.setSavePoint();
        Order__c[] suborder = [SELECT Name FROM Order__c WHERE Name =: suborder_no];
        if(suborder.size() > 0){
            List<Opportunity> oppToUpdate = new List<Opportunity>();
            for(Order__c ordr : suborder){
                Id oppId = ordr.Opportunity_Name__c;
                oppToUpdate = [SELECT Id FROM Opportunity WHERE Id =: oppId AND StageName <> 'Closed / Lost'];
                if(oppToUpdate.size() > 0){
                    for(Opportunity o : oppToUpdate){
                        o.StageName = 'Closed / Lost';
                    }
                    update oppToUpdate;
                    return 'success';
                }
                else{
                    return 'Error: opportunity already closed';
                }
            }
            return '??';
        }
        else{
            return 'Error: suborder does not exist';
        }
    }
    else{
        return 'Error: no suborder was passed to service';
    } 
}  

 

  • February 14, 2013
  • Like
  • 0

Hello,

 

I have the below trigger which works but fails the test code (also included below). Any help is greatly appreciated!!

 

trigger createNewOpportunity on Order__c (after insert, after update) {

    Id orderRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Order__c' and Name = 'Order'].Id;
    Id oppRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND Name = 'Non-Profit'].Id;
    Id TTO = [SELECT Id FROM Account WHERE Agreement_Company_Code__c = 'W'].Id;
    

    // collection of Group Names for creating opp/portfolio records
    Set<String> groups = new Set<String>();
    for (Order__c o : Trigger.new){
        if (o.Opportunity_Name__c <> Null && o.Status__c == 'Opportunity Created'){
            groups.add('Order Mgmt - ' + o.Group__c);
        }
    }

    // Map of Portfolios matching the groups set above
    Map<String, Portfolio_Lookup__c> ports = new Map<String, Portfolio_Lookup__c>();
    if (groups.size() > 0){
        for (Portfolio_Lookup__c pl : [SELECT Name FROM Portfolio_Lookup__c WHERE IsDeleted = False AND Name IN :groups]){
            ports.put(pl.Name, pl);
        }
    }

    // List of Organizations to get Org Name for opportunity name below
    List<Id> OrgIds = new List<Id>();
    for (Order__c ord : Trigger.new){
        OrgIds.add(ord.Account__c);
    }
    
    Map<Id, Account> mp = new map<Id, Account>([SELECT Id, Name FROM Account WHERE Id IN :OrgIds]);

    List<Opportunity> o = new List<Opportunity>();
    List<Portfolio_Opportunity__c> po = new List<Portfolio_Opportunity__c>();
        for (Order__c order: Trigger.New){
            if ((Trigger.isInsert && order.Contact__c <> Null && order.Account__c <> Null && order.RecordTypeId == orderRT && order.Status__c == 'Open') || (Trigger.isUpdate && order.Contact__c <> Null && order.Account__c <> Null && order.RecordTypeId == orderRT && order.Status__c == 'Open' && Trigger.oldMap.get(order.Id).Status__c == 'Open')){
                //Generate Opportunity Number
                getOppNumber controller = new getOppNumber();
                string oppNumber = controller.generateOpportunityNumber(TTO);
                //Insert New Opportunity
                o.add(new Opportunity(
                    RecordTypeId = oppRT,
                    Record_Sub_Type__c = 'Simple Agreement',
                    AccountId = order.Account__c,
                    Opportunity_Number__c = oppNumber,
                    StageName = 'Initial Contact/Exploration',
                    Suborder_Id__c = order.Id,
                    CloseDate = system.today().addDays(90),
                    Name = mp.get(order.Account__c).Name + oppNumber.removeStart('D'))); 
             }
             else if (Trigger.isUpdate && Trigger.oldMap.get(order.Id).Status__c != order.Status__c && order.Status__c == 'Opportunity Created'){
             //Create new Portfolio_Opportunity__c record to link the correct product group portfolio record
                 po.add(new Portfolio_Opportunity__c(
                    Opportunity_Name__c = order.Opportunity_Name__c,
                    Portfolio__c = ports.get('Order Mgmt - ' + order.Group__c).Id));       
             }
       }
       if (o.size() > 0) {
           insert o; //Insert Opportunities
       }    
       if (po.size() > 0){ //Insert Portfolio_Opportunity__c records
           insert po;
       }         
}

 

Test Code:

public class Trigger_TestCode_Order
{
   
    static testMethod void testcreateNewOpportunity()
    {        
        //Create New Account (Org) Record
        Account newAcct = new Account();
        newAcct.Name = 'Bubba Gump Shrimp Co';
        newAcct.RecordTypeId = '012500000005HjFAAU';
        insert(newAcct);
        Id OrgId = newAcct.Id; 
        
        //Create New Account (Org) Record for TTO
        Account newAct = new Account();
        newAct.Name = 'WiCell';
        newAct.RecordTypeId = '012500000005HjFAAU';
        newAct.Agreement_Company_Code__c = 'W';
        insert(newAct);
        
        //Create New Contact Record to link to Account
        Contact newCon = new Contact();
        newCon.FirstName = 'Tommy';
        newCon.LastName = 'Tucker';
        insert(newCon);
        Id ContactId = newCon.Id;        
        
        //Create New Order Record
        Id orderRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Order__c' and Name = 'Order' and IsActive = True LIMIT 1].Id;
        Order__c odr = new Order__c();
        odr.RecordTypeId = orderRT;
        odr.Name = '999999';
        odr.Status__c = 'Open';
        odr.Group__c = 'WI';
        odr.PI_Name__c = 'Susie Smith';
        odr.Contact__c = ContactId;
        odr.Account__c = OrgId;
        insert(odr);
        String odrID = odr.Name;        
    }
}

 

  • February 07, 2013
  • Like
  • 0

The below trigger creates opportunity records once order__c records meet certain criteria. The order__c table has a field called Opportunity_Name__c that I would like to populate with the opportunity Id that is generated in the trigger. Can someone show me how to do this?

 

trigger createNewOpportunity on Order__c (after update) {

    Id orderRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Order__c' and Name = 'Order'].Id;
    Id oppRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND Name = 'CDA'].Id;
    Id TTO = [SELECT Id FROM Account WHERE Agreement_Company_Code__c = 'W'].Id;
       

    List<Opportunity> o = new List<Opportunity>();
        for (Order__c order: Trigger.New){
            if (order.Contact__c <> Null && order.Account__c <> Null && order.RecordTypeId == orderRT && order.Status__c == 'Open'){
                getOppNumber controller = new getOppNumber();
                string oppNumber = controller.generateOpportunityNumber(TTO);
                o.add(new Opportunity(
                    RecordTypeId = oppRT,
                    Record_Sub_Type__c = 'Confidential Agreement',
                    AccountId = order.Account__c,
                    Opportunity_Number__c = oppNumber,
                    StageName = 'Initial Contact',
                    Name = order.Account__r.Name + ' - ' + order.PI_Name__c + ' - ' + oppNumber.removeStart('D'))); 
             }
       }
       insert o;            
}

 

  • February 05, 2013
  • Like
  • 0

Hello,

 

Can anyone help me bulkify the below trigger? I would like to insert the same Test_Opportunity__c records to the current opportunity record as was attached to the opportunity I cloned from (using the Opportunity_Clone_Id__c field).

 

 

trigger CreateOpportunityRelated on Opportunity (after insert) 
{ 

    for (Opportunity opp : Trigger.new)     
    { 
        ID cloneID = opp.Opportunity_Clone_ID__c; //OPPORTUNITY WE'RE CLONING FROM 
        ID oppID = opp.Id; //OPPORTUNITY WE CLONED INTO


        List<Test_Opportunity__c> tps = new List<Test_Opportunity__c>(); //EMPTY LIST OF TEST OPPORTUNITY OBJECTS 

        //POPULATE Test OPPORTUNITY OBJECTS
        for (Test_Opportunity__c test_opp : [SELECT Test_Number__c FROM Test_Opportunity__c WHERE Opportunity_Name__c = :cloneID])
        {
                        Test_Opportunity__c new_test_opp = New Test_Opportunity__c(
                        Opportunity_Name__c = oppId, 
                        Test_Number__c = test_opp.Test_Number__c);
                        tps.add(new_test_opp);
        }
        INSERT tps; //DO A SINGLE INSERT OF ALL Test OPPORTUNITY RECORDS 
    }
}

 Thank you!

  • February 04, 2013
  • Like
  • 0

I have a REST class that creates new lead records. See below:

 

@RestResource(urlMapping='/v.1/leads/*')
global with sharing class LeadRestSvc {


    @HttpPost
    global static String doPost(String firstname, String lastname) {
    
        RestRequest req = RestContext.request;

        //see if a name was part of the URI     
        String leadName = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

        if (leadName == '') {
            Savepoint sp = Database.setSavePoint();
            
            try {
    
                //populate a new Lead object
                Lead l = new Lead();
                l.FirstName = firstname;
                l.LastName = lastname;
                insert l;
                return 'success';
            }

            catch (DMLException e1) {
                Database.rollback(sp);
                return e1.getDMLMessage(0);
            }
            catch (Exception e2) {
                Database.rollback(sp);
                return e2.getMessage();
            }
        }
        else {
            return 'Invalid operation';
        }
    }

Now I need to write a unit test and am having difficulty. I've tried following the few GET examples online but without success.

 

I tried the following but I get this error : "Compile Error: Option already set: TestMethod "

 

    @isTest
    static testmethod void testDoPost(){
        
        RestRequest req = new RestRequest(); 
        RestResponse res = new RestResponse();
 
        req.requestURI = 'https://XXXX.salesforce.com/services/apexrest/v.1/leads/';
        req.httpMethod = 'POST';
        RestContext.request = req;
        RestContext.response = res;
   RestContext.request.addHeader('firstname','Wain','lastname','Rolen');
        String results = LeadRestSvc.doPost();       
    }  

Also, am I supposed to hardcode the requestURI? It seems that the unit test won't work when I try to move this code into my production environment.

 

I appreciate the assistance!

I would like to update a Self-Service User record via an OM when the related contact record is updated. The below code is generating the following error: Object reference not set to an instance of an object.

 

I appreciate the help!

 

 

for (int i = 0; i < contacts.Length; i++)
        {
            EditContactNotification.ContactNotification notification = contacts[i];
            EditContactNotification.Contact contact = (EditContactNotification.Contact)notification.sObject;
            
            EnterpriseWebReference.QueryResult qr = null;
            try
            {
                qr = binding.query("SELECT Id FROM SelfServiceUser WHERE ContactId = " + contact.Id);
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Query didn't work " + e.Message);
            }

            if (qr.size > 0)
            {
                EnterpriseWebReference.sObject[] records = qr.records;
                for (int x = 0; x < records.Length; x++)
                {
                    EnterpriseWebReference.SelfServiceUser var = ((EnterpriseWebReference.SelfServiceUser)records[x]);
                    EnterpriseWebReference.SelfServiceUser ssu = new EnterpriseWebReference.SelfServiceUser();
                    ssu.Id = var.Id;
                    ssu.ContactId = contact.Id;
                    ssu.FirstName = contact.FirstName;
                    ssu.LastName = contact.LastName;
                    ssu.Username = contact.Email;
                    ssu.Email = contact.Email;
                    EnterpriseWebReference.SaveResult[] saveResults = binding.update(new EnterpriseWebReference.sObject[] { ssu });
                }

 

 

 

I'm trying to update a SelfServiceUser record based on an update to a Contact record. I have an OM configured to call the web service when the contact record is edited. Since I don't have the SSU Id I need to query for it based on the contact Id. I can't seem to figure out how to access the Id from the query. This is my first C# experience. Thanks in advance

 

        EditContactNotification.ContactNotification[] contacts = notifications1.Notification;
        for (int i = 0; i < contacts.Length; i++)
        {
            EditContactNotification.ContactNotification notification = contacts[i];
            EditContactNotification.Contact contact = (EditContactNotification.Contact)notification.sObject;

            EnterpriseWebReference.QueryResult qr = null;
            qr = binding.query("SELECT Id FROM SelfServiceUser WHERE ContactId = " + contact.Id);

            for (int x = 0; x < qr.records.Length; x++)
            {
                EnterpriseWebReference.sObject ssu2Update = qr.records(x);
                EnterpriseWebReference.SelfServiceUser ssu = new EnterpriseWebReference.SelfServiceUser();
                ssu.Id = ssu2Update.Id;
                ssu.ContactId = contact.Id;
                ssu.FirstName = contact.FirstName;
                ssu.LastName = contact.LastName;
                ssu.Username = contact.Email;
                ssu.Email = contact.Email;
                EnterpriseWebReference.SaveResult[] saveResults = binding.update(new EnterpriseWebReference.sObject[] { ssu });
            }
        }
        EditContactNotification.notificationsResponse response = new EditContactNotification.notificationsResponse();
        response.Ack = true;
        return response;

 

the below line generates the following error: Non-invocable member EnterpriseWebReference.QueryResult.records cannot be used like a method.

 

EnterpriseWebReference.sObject ssu2Update = qr.records(x);

 

I'm getting the above error message and I'm assuming this has to do with my authentication code below. The .NET web service is being called from an outbound message in my sandbox environment. The .Net service references the enterprise WSDL, URL, username and password+security token from the sandbox. I also added the server address where the web service is hosted to the trusted IP page in Salesforce (although I don't think this is necessary since it's located on our network). Your advice is appreciated!

 

EnterpriseWebReference.SforceService binding = new EnterpriseWebReference.SforceService();
        EnterpriseWebReference.LoginResult loginResult = new EnterpriseWebReference.LoginResult();

        binding.Url = "https://test.salesforce.com/services/Soap/c/25.0";
        loginResult = binding.login("username", "password+token");

        binding.SessionHeaderValue = new EnterpriseWebReference.SessionHeader();
        binding.SessionHeaderValue.sessionId = loginResult.sessionId;

 

Hi,

 

I'm looking for the easiest way to programmatically create self-service user accounts. I initially wanted to do this via an Apex REST class; however, I see that I cannot perform any DML operations against the SelfServiceUser object in Apex.

 

Do I really need to create an external web service that I call from my Apex REST class? It looks like creating self-service users via the API is possible.

 

I appreciate any suggestions and advice.

 

Thanks!

Hi,

 

I've written my first REST API class and now I need to understand how an external application can authenticate with my Salesforce instance and call the class. As I understand it, OAuth presents an actual login screen where someone needs to manually type in credentials, is this correct? If so, it looks like I need to have the external application authenticate via a Session ID.

 

The REST API documentation mentions "you can use a session ID instead of an OAuth 2.0 access token if you aren't handling someone else's password". I don't understand what this means. Can anyone explain this?

 

Also, if anyone can share a small snippet of code that authenticates (without a login screen) with SF and calls a REST Apex Class I would greatly appreciate it!!

 

Thanks in advance.

Hello,

I am trying to migrate profiles from one Salesforce environment to another via Eclipse. While attempting to deploy profiles, I am receiving the following error:
-------------------------------------------------------------------------
In field: recordType - no RecordType named Idea.Record_type_for_community_09a500000008b62AAA_entity_Idea found
-------------------------------------------------------------------------

This led me to believe that I first need to deploy the Idea object and it's related settings. When I attempt to deploy the Idea object I receive the below errors:
-------------------------------------------------------------------------
File Name:    objects/Idea.object
   Full Name:  Idea.InternalIdeasIdeaRecordType
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.Record_type_for_community_09a500000008b62AAA_entity_Idea
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.Record_type_for_community_09a500000008b67AAA_entity_Idea
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.Record_type_for_community_09a500000008b6CAAQ_entity_Idea
   Action:  NO ACTION
   Result:  FAILED
   Problem: You are not allowed to modify record types on Idea

   File Name:    objects/Idea.object
   Full Name:  Idea.All_WF_Ideas
   Action:  NO ACTION
   Result:  FAILED
   Problem: Could not resolve list view column: IDEA.CATEGORY

   File Name:    objects/Idea.object
   Full Name:  Idea.Ideas_Last_7_Days
   Action:  NO ACTION
   Result:  FAILED
   Problem: Could not resolve list view column: IDEA.IDEA_THEME
-------------------------------------------------------------------------

I see that I cannot create or edit record types on the Ideas object and I don't see communities referenced on the Ideas object anymore. I think they might have been replaced by zones? In Eclipse the zones are stored under a folder called 'Communities' and I was able to deploy them but my errors still remain. Any assistance is appreciated! I hope there is a solution to this otherwise I may be forced to manually recreate all my profiles by hand.

Thanks in advance.
  • January 13, 2014
  • Like
  • 1

Hello,

 

I have a request to display some data on a Salesforce dashboard that does not reside in Salesforce. Therefore, I'm trying to create a Visualforce page that will display the static data. I would like the Visualforce dashboard component to look like image A (below).

 

Image A:



 

My current Visualforce code is as follows:

 

<apex:page>
    <apex:pageBlock mode="maindetail">
        <apex:pageblocksection columns="1">
            <apex:outputText value="Value A: 0"/>
        </apex:pageblocksection>
        <apex:pageblocksection columns="1">
            <apex:outputLabel value="Value B: 0"/>            
        </apex:pageblocksection>
        <apex:pageblocksection columns="1">
            <apex:outputLabel value="Value C: 0"/>            
        </apex:pageblocksection>
    </apex:pageBlock>
</apex:page>



This gets the data I want to display on the dashboard but it's not formatted like image A. It looks like image B (below).

 

Image B:



I would really like the text and the value to be stored in separate cells (with the right-hand cell being right-aligned) and have the alternating backgroud color if possible.

 

ANY help is greatly appreciated!!

  • August 25, 2011
  • Like
  • 1
I use the below javascript button to auto populate recipients from a custom object called RvMembers (similar to the contact object) on the related list of the RVAccount (similar to the account object) when sending documents for signature using docusign. 
Problem is it works if there are more than one member in the related list but it does not populate if there is only one member in the related list. I believe it has to do with the query but i'm new to javascript so need help asap.


{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}

//
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}

//********* Option Declarations (Do not modify )*********//
var RC = '';
var RSL='';
var RSRO='';
var RROS='';
var CCRM='';
var CCTM='';
var CCNM='';
var CRCL='';
var CRL='';
var DST='';
var LA='';
var CEM='';
var CES='';
var STB='';
var SSB='';
var SES='';
var SEM='';
var SRS='';
var SCS ='';
var RES='';
var OCO='';
var debug = false;

//*************************************************//
/* Encode all variables from data with left brace bang URLENCODE( bang JSENCODE(salesforceobject.salesforcefield))}  */



function foundRVAccountAnyMembers()
{

      var RVAccountAnyMembers = 'Not Found';
     
      try
      {
       var result = sforce.connection.query("Select id, (Select Id, Name, rvpe__Email__c, rvpe__ExtMemberId__c, rvpe__FirstName__c, rvpe__LastName__c, rvpe__RVAccount__c From rvpe__RVMembers__r  ) From rvpe__RVAccount__c r where id = '{!rvpe__RVAccount__c.Id}' LiMIT 1");
      
       var records = result.getArray("records");
      
       if (records.length != 0)
       {
      
      RVAccountAnyMembers = 'Records Found';
       }
    }
    catch(error)
    {
     if (debug)
     {
      alert('Exception Name: '+error.name+ 'Exception Message:' + error.message);
     }
    }
    finally
    {
     if (debug)
     {
      alert('Finally - foundRVAccountAnyMembers: RVAccountAnyMembers = '+RVAccountAnyMembers);
     }
    }
              
               return RVAccountAnyMembers;
}


function getMembersInfoasCRL()
{

    
       try
       {
       var result = sforce.connection.query("Select id, (Select Id, Name, rvpe__Email__c, rvpe__ExtMemberId__c, rvpe__FirstName__c, rvpe__LastName__c, rvpe__RVAccount__c From rvpe__RVMembers__r  ) From rvpe__RVAccount__c r where id = '{!rvpe__RVAccount__c.Id}' LiMIT 99");
      
       var records = result.getArray("records");
                                   for(recs1 = 0; recs1 <100; recs1++ )
                                   {
       var RVMembers = records[recs1].get("rvpe__RVMembers__r");
              var contact = RVMembers.get("records");

       for(recs = 0; recs <100; recs++ )
                                     
       {
    
      var contactEmail = contact[recs].rvpe__Email__c;
      var contactFirstName = contact[recs].rvpe__FirstName__c;
      var contactLastName = contact[recs].rvpe__LastName__c;

      if(contactEmail==null)
      {
       alert('Member is missing email, correct and then send again');
       return;
      }
      if(contactFirstName==null)
      {
       alert('Member is missing FirstName, correct and then send again');
       return;
      }
      if(contactLastName==null)
      {
       alert('Member is missing LastName, correct and then send again');
       return;
      }
    
      CRL=CRL+'Email~'+contactEmail+';FirstName~'+contactFirstName+';LastName~'+contactLastName+';,';
     
       }
                                  }
    }
    catch(error)
    {
     if (debug)
     {
      alert('Exception Name: '+error.name+ 'Exception Message:' + error.message);
     }
    }
    finally
    {
     if (debug)
     {
      alert('Finally - getMembersInfoasCRL: CRL = '+CRL);

     }
    }
              
               return ;
}

function getDataForDocuSign()
{

var RVAccountAnyMembers = foundRVAccountAnyMembers();

if(foundRVAccountAnyMembers=='Not Found')
{
  return;
}
else
{
  getMembersInfoasCRL();
 
  if(CRL=='')
  {
   return;
  }
}



var newLocation ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!rvpe__RVAccount__c.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//********* Page Callout (Do not modify) *********//
if (debug) {
  alert(newLocation);
} else {
  window.location.href = newLocation;
}
}

//*******************************************//

getDataForDocuSign();
Hello,

I have a related list that is a visualforce page. I am trying to use a commandlink to delete records from the related list; however, the code is not working. There is no error message displayed. Any assistance is appreciated!

VF page:
<apex:commandlink value="Del" id="customDelete" onClick="return confirmDelete()">
    <apex:param name="delID" value="{!attorney.ID_1__c}" assignTo="{!SelectedId}"/>
</apex:commandlink>

Class:
public void customDelete()
    {
        New List<Att_IP__c> att = [SELECT Id FROM Att_IP__c WHERE Id = :SelectedId];
        if (att.size() > 0){
            Delete att;
        }
    }


I am looking to create an exact clone of our production Salesforce instance into a new, completely separate enterprise instance of Salesforce. I would like everything to clone over such as custom objects, fields, triggers, workflows, apex classes, visualforce pages, etc. Has anyone been through a similar situation? I'm looking for all and any advice on the easiest way to complete this task.

 Thank you in advance!!

  • November 11, 2013
  • Like
  • 0

Hello,

 

The below code was written by someone else and basically it's constructing a URL to a page that downloads a file. Generate() is called by a button click on a VF page. After the button is clicked the user is presented with a white/blank browser page while the file is downloaded. The user then has to click the browser back button to return to the page they clicked the button. I would prefer to have the user stay on the Salesforce page when the button is clicked and have the file download. Any ideas what I might try?

 

The custom button was set to open in a new window and I changed it to display in current window with sidebar. The URL for the button is /apex/ReportParm?Id={!Custom_Reports__c.Id}&Name={!Custom_Reports__c.Name}&URL={!Custom_Reports__c.Report_URL__c}

 

Note, the sidebar does not display when the button is clicked...just a blank, white screen.

 

public class CustomReports_Extension 
{
    Transport__c transport;
    
    string strReportId;
    string strReportName;
    string strURL;
    string strPath;
    integer parmNum;
    string errorMessage;
    
    Report_Parameters__c parms_1;
    Report_Parameters__c parms_2;
    Report_Parameters__c parms_3;
    Report_Parameters__c parms_4;
    Report_Parameters__c parms_5;
    
    List<string> multiPickList_1 = new List<string>();
    List<string> multiPickList_2 = new List<string>();
    List<string> multiPickList_3 = new List<string>();
    List<string> multiPickList_4 = new List<string>();
    List<string> multiPickList_5 = new List<string>();
    
    public CustomReports_Extension(ApexPages.StandardController controller) 
    {
        this.transport = new Transport__c();

        strReportId = System.currentPageReference().getParameters().get('Id'); 
        strReportName = System.currentPageReference().getParameters().get('Name');
        strURL = System.currentPageReference().getParameters().get('URL'); 
        
        List<Report_Parameters__c> parms = new List<Report_Parameters__c>();

        parms = [SELECT Parameter_Label__c, Parameter_Order__c, Name, Render_Text__c, 
                    Render_Date__c, Render_Checkbox__c, Render_Select_List__c, Render_Multi_Select_List__c 
                 FROM Report_Parameters__c WHERE Report_Number__c = :strReportId ORDER BY Parameter_Order__c];

        parmNum = parms.size();
    }
    
    public CustomReports_Extension(Transport__c transporter) 
    {
        this.transport = transporter;
        
        strReportId = System.currentPageReference().getParameters().get('Id');
        strReportName = System.currentPageReference().getParameters().get('Name');
        strURL = System.currentPageReference().getParameters().get('URL'); 
        
        List<Report_Parameters__c> parms = new List<Report_Parameters__c>();

        parms = [SELECT Parameter_Label__c, Parameter_Order__c, Name, Render_Text__c, 
                    Render_Date__c, Render_Checkbox__c, Render_Select_List__c, Render_Multi_Select_List__c  
                 FROM Report_Parameters__c WHERE Report_Number__c = :strReportId ORDER BY Parameter_Order__c];

        parmNum = parms.size();
    }

    public PageReference ParameterCheck()
    {
        string strPath;
        PageReference thisPage;
        
        if (parmNum == 0) //NO PARAMETERS NEEDED
        {
            strPath = strURL;
            thisPage = new PageReference(strPath); 
            thisPage.setRedirect(true);
        }
    
        return thisPage;
    }    

    public pageReference generate()
    {
        string strParmValues = ''; 
        string strParmName = '';
        
        if (parmNum == 0)
        {
            strPath = strURL;
        }
        else
        {
           //PARM 1
           if (parms_1.Render_Text__c == True)
           {
                if (Transport.Name_1_40__c == '' || Transport.Name_1_40__c == ' ')
                {
                    PageReference thisPage = page.ReportParm;
                    thisPage.setRedirect(false);
                    setError();

                    return thisPage;
                }
                else
                {
                    strParmValues = parms_1.Name + '=' + Transport.Name_1_40__c;
                }
           }                   
        }     
        strPath = strURL + '?' + strParmValues;

        PageReference thisPage = new PageReference(strPath);  
        thisPage.setRedirect(true);

        return thisPage;
    }
}

 Thank you.

 

  • October 15, 2013
  • Like
  • 0

Hello,

 

I have a workflow that calls an outbound message (OM) and passes the following values: email, firstname, lastname, id, self_service_password__c.

 

When the OM fires, I receive the following error: MALFORMED_ID: bad id lgQFM4sP. lgQFM4sP is the value in the self_service_password__c field.

 

Here is my code that the OM is calling:

 

        ContactNotification.ContactNotification[] contacts = notifications1.Notification;
        for (int i = 0; i < contacts.Length; i++)
        {
            ContactNotification.ContactNotification notification = contacts[i];
            ContactNotification.Contact contact = (ContactNotification.Contact)notification.sObject;
            
            EnterpriseWebReference.SelfServiceUser ssu = new EnterpriseWebReference.SelfServiceUser();
            ssu.ContactId = contact.Id;
            ssu.FirstName = contact.FirstName;
            ssu.LastName = contact.LastName;
            ssu.Username = contact.Email;
            ssu.Email = contact.Email;
            ssu.TimeZoneSidKey = "America/Chicago";
            ssu.LocaleSidKey = "en_US";
            ssu.LanguageLocaleKey = "en_US";
            ssu.IsActive = true;
            ssu.IsActiveSpecified = true;
            EnterpriseWebReference.SaveResult[] saveResults = binding.create(new EnterpriseWebReference.sObject[] { ssu });
            
            for (int a = 0; a < saveResults.Length; a++)
            {
                EnterpriseWebReference.SetPasswordResult result = binding.setPassword(saveResults[a].id, contact.Self_Service_Password__c);
            }
            
            
        }
        ContactNotification.notificationsResponse response = new ContactNotification.notificationsResponse();
        response.Ack = true;
        return response;

 Any help is appreciated!

Hi All,

 

I'm getting the following error: System.LimitException: Too many SOQL queries: 101. I didn't think my query was inside a loop so I'm unsure how to fix the problem. Your help is greatly appreciated!

 

trigger setContactAndAccountIdOnOrder on Lead (after update) {

    Map<String,Id> Ids = new Map<String,Id>(); 

    for(Lead lead : Trigger.new) {
        if (lead.IsConverted) {
            Ids.put(lead.Person_Id__c,lead.Id);
        }
    } 
    
    List<Order__c> orders = [select Id, Person_Id__c, Contact__c, Account__c from Order__c WHERE Person_Id__c IN :Ids.keySet()];
        for (Order__c o : orders) { 
            Id personId = Ids.get(o.Person_Id__c);
            Lead ld = trigger.newMap.get(personId);
            o.Contact__c = ld.ConvertedContactId;
            o.Account__c = ld.ConvertedAccountId;
        }
        update orders;        
}

 

  • April 25, 2013
  • Like
  • 0

Hello,

 

Can someone help me refactor the below code? If I take out the line return '??'; below then I get the following error:

 

Compile Error: Non-void method might not return a value or might have statement after a return statement. at line

 

I don't understand why I need to return something at line 73 (where I have return '??')

 

Thanks in advance!

 

 

    @HttpPatch
    global static String doPatch() {
    
    RestRequest req = RestContext.request;
    
    // see if a suborder number was part of the uri
    String suborder_no = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    
    if (suborder_no != ''){
        Savepoint sp = Database.setSavePoint();
        Order__c[] suborder = [SELECT Name FROM Order__c WHERE Name =: suborder_no];
        if(suborder.size() > 0){
            List<Opportunity> oppToUpdate = new List<Opportunity>();
            for(Order__c ordr : suborder){
                Id oppId = ordr.Opportunity_Name__c;
                oppToUpdate = [SELECT Id FROM Opportunity WHERE Id =: oppId AND StageName <> 'Closed / Lost'];
                if(oppToUpdate.size() > 0){
                    for(Opportunity o : oppToUpdate){
                        o.StageName = 'Closed / Lost';
                    }
                    update oppToUpdate;
                    return 'success';
                }
                else{
                    return 'Error: opportunity already closed';
                }
            }
            return '??';
        }
        else{
            return 'Error: suborder does not exist';
        }
    }
    else{
        return 'Error: no suborder was passed to service';
    } 
}  

 

  • February 14, 2013
  • Like
  • 0

Hello,

 

I have the below trigger which works but fails the test code (also included below). Any help is greatly appreciated!!

 

trigger createNewOpportunity on Order__c (after insert, after update) {

    Id orderRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Order__c' and Name = 'Order'].Id;
    Id oppRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND Name = 'Non-Profit'].Id;
    Id TTO = [SELECT Id FROM Account WHERE Agreement_Company_Code__c = 'W'].Id;
    

    // collection of Group Names for creating opp/portfolio records
    Set<String> groups = new Set<String>();
    for (Order__c o : Trigger.new){
        if (o.Opportunity_Name__c <> Null && o.Status__c == 'Opportunity Created'){
            groups.add('Order Mgmt - ' + o.Group__c);
        }
    }

    // Map of Portfolios matching the groups set above
    Map<String, Portfolio_Lookup__c> ports = new Map<String, Portfolio_Lookup__c>();
    if (groups.size() > 0){
        for (Portfolio_Lookup__c pl : [SELECT Name FROM Portfolio_Lookup__c WHERE IsDeleted = False AND Name IN :groups]){
            ports.put(pl.Name, pl);
        }
    }

    // List of Organizations to get Org Name for opportunity name below
    List<Id> OrgIds = new List<Id>();
    for (Order__c ord : Trigger.new){
        OrgIds.add(ord.Account__c);
    }
    
    Map<Id, Account> mp = new map<Id, Account>([SELECT Id, Name FROM Account WHERE Id IN :OrgIds]);

    List<Opportunity> o = new List<Opportunity>();
    List<Portfolio_Opportunity__c> po = new List<Portfolio_Opportunity__c>();
        for (Order__c order: Trigger.New){
            if ((Trigger.isInsert && order.Contact__c <> Null && order.Account__c <> Null && order.RecordTypeId == orderRT && order.Status__c == 'Open') || (Trigger.isUpdate && order.Contact__c <> Null && order.Account__c <> Null && order.RecordTypeId == orderRT && order.Status__c == 'Open' && Trigger.oldMap.get(order.Id).Status__c == 'Open')){
                //Generate Opportunity Number
                getOppNumber controller = new getOppNumber();
                string oppNumber = controller.generateOpportunityNumber(TTO);
                //Insert New Opportunity
                o.add(new Opportunity(
                    RecordTypeId = oppRT,
                    Record_Sub_Type__c = 'Simple Agreement',
                    AccountId = order.Account__c,
                    Opportunity_Number__c = oppNumber,
                    StageName = 'Initial Contact/Exploration',
                    Suborder_Id__c = order.Id,
                    CloseDate = system.today().addDays(90),
                    Name = mp.get(order.Account__c).Name + oppNumber.removeStart('D'))); 
             }
             else if (Trigger.isUpdate && Trigger.oldMap.get(order.Id).Status__c != order.Status__c && order.Status__c == 'Opportunity Created'){
             //Create new Portfolio_Opportunity__c record to link the correct product group portfolio record
                 po.add(new Portfolio_Opportunity__c(
                    Opportunity_Name__c = order.Opportunity_Name__c,
                    Portfolio__c = ports.get('Order Mgmt - ' + order.Group__c).Id));       
             }
       }
       if (o.size() > 0) {
           insert o; //Insert Opportunities
       }    
       if (po.size() > 0){ //Insert Portfolio_Opportunity__c records
           insert po;
       }         
}

 

Test Code:

public class Trigger_TestCode_Order
{
   
    static testMethod void testcreateNewOpportunity()
    {        
        //Create New Account (Org) Record
        Account newAcct = new Account();
        newAcct.Name = 'Bubba Gump Shrimp Co';
        newAcct.RecordTypeId = '012500000005HjFAAU';
        insert(newAcct);
        Id OrgId = newAcct.Id; 
        
        //Create New Account (Org) Record for TTO
        Account newAct = new Account();
        newAct.Name = 'WiCell';
        newAct.RecordTypeId = '012500000005HjFAAU';
        newAct.Agreement_Company_Code__c = 'W';
        insert(newAct);
        
        //Create New Contact Record to link to Account
        Contact newCon = new Contact();
        newCon.FirstName = 'Tommy';
        newCon.LastName = 'Tucker';
        insert(newCon);
        Id ContactId = newCon.Id;        
        
        //Create New Order Record
        Id orderRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Order__c' and Name = 'Order' and IsActive = True LIMIT 1].Id;
        Order__c odr = new Order__c();
        odr.RecordTypeId = orderRT;
        odr.Name = '999999';
        odr.Status__c = 'Open';
        odr.Group__c = 'WI';
        odr.PI_Name__c = 'Susie Smith';
        odr.Contact__c = ContactId;
        odr.Account__c = OrgId;
        insert(odr);
        String odrID = odr.Name;        
    }
}

 

  • February 07, 2013
  • Like
  • 0

The below trigger creates opportunity records once order__c records meet certain criteria. The order__c table has a field called Opportunity_Name__c that I would like to populate with the opportunity Id that is generated in the trigger. Can someone show me how to do this?

 

trigger createNewOpportunity on Order__c (after update) {

    Id orderRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Order__c' and Name = 'Order'].Id;
    Id oppRT = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND Name = 'CDA'].Id;
    Id TTO = [SELECT Id FROM Account WHERE Agreement_Company_Code__c = 'W'].Id;
       

    List<Opportunity> o = new List<Opportunity>();
        for (Order__c order: Trigger.New){
            if (order.Contact__c <> Null && order.Account__c <> Null && order.RecordTypeId == orderRT && order.Status__c == 'Open'){
                getOppNumber controller = new getOppNumber();
                string oppNumber = controller.generateOpportunityNumber(TTO);
                o.add(new Opportunity(
                    RecordTypeId = oppRT,
                    Record_Sub_Type__c = 'Confidential Agreement',
                    AccountId = order.Account__c,
                    Opportunity_Number__c = oppNumber,
                    StageName = 'Initial Contact',
                    Name = order.Account__r.Name + ' - ' + order.PI_Name__c + ' - ' + oppNumber.removeStart('D'))); 
             }
       }
       insert o;            
}

 

  • February 05, 2013
  • Like
  • 0

Hello,

 

Can anyone help me bulkify the below trigger? I would like to insert the same Test_Opportunity__c records to the current opportunity record as was attached to the opportunity I cloned from (using the Opportunity_Clone_Id__c field).

 

 

trigger CreateOpportunityRelated on Opportunity (after insert) 
{ 

    for (Opportunity opp : Trigger.new)     
    { 
        ID cloneID = opp.Opportunity_Clone_ID__c; //OPPORTUNITY WE'RE CLONING FROM 
        ID oppID = opp.Id; //OPPORTUNITY WE CLONED INTO


        List<Test_Opportunity__c> tps = new List<Test_Opportunity__c>(); //EMPTY LIST OF TEST OPPORTUNITY OBJECTS 

        //POPULATE Test OPPORTUNITY OBJECTS
        for (Test_Opportunity__c test_opp : [SELECT Test_Number__c FROM Test_Opportunity__c WHERE Opportunity_Name__c = :cloneID])
        {
                        Test_Opportunity__c new_test_opp = New Test_Opportunity__c(
                        Opportunity_Name__c = oppId, 
                        Test_Number__c = test_opp.Test_Number__c);
                        tps.add(new_test_opp);
        }
        INSERT tps; //DO A SINGLE INSERT OF ALL Test OPPORTUNITY RECORDS 
    }
}

 Thank you!

  • February 04, 2013
  • Like
  • 0

Perhaps I'm missing something here but I can't find any docs or way to write unit tests for Apex REST classes for v24. Here's my class:

 

@RestResource(urlMapping='/v.9/member/*/results/*') 
global with sharing class MemberRestSvc {
 
  @HttpGet
  global static String doGet() {
  
    String[] uriKeys = RestContext.request.requestURI.split('/');
    // do awesome programming stuff here

  }
    
}

 

With a v23, I would typically write a test like:

 

RestRequest req = new RestRequest(); 
RestResponse res = new RestResponse();
 
req.requestURI = 'https://cs9.salesforce.com/services/apexrest/v.9/member/me/results/today';  
req.httpMethod = 'GET';

String results = MemberRestSvc.doGet(req, res);
System.assertEquals('awesomeness-happened',results);

 

However, I can't figure out how to specify the requestURI. It looks like the the System.RestContext class is not writeable? I keep getting NPEs. Any help would be greatly appreciated.

 

Thanks

Jeff Douglas

Appirio / CloudSpokes

http://blog.jeffdouglas.com