• sharris
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 15
    Replies

Hi Friends,

 

 

I am trying to extract records from salesforce through the data loader

All I want to do is to extract contacts fromn a  particular record type and on a particular date.

 

So I am doing

 

select * from contacts where record type = 'some number' and  createddate=2011-9-29.

 

But I get an error  saying that createddate has to of type datetime and should not have quotes enclosed to it.

 

I am supplying date type value and am not enclosing in quotes them why am I getting an error.

 

Please tell me the right way to extract contact records based on date and recordtype.

 

Thanks,

Trick009

 

 

 

 

 

 

 

 

 

  • October 01, 2011
  • Like
  • 0

I need to have page breaks in text that I'm displaying in an apex:pageblocktable.

How can I get the text to not show the literal "<br />" tags? "\n" new line escape doesn't seem to be rendered as a <br/> tag. When I replaceAll "\n" with <br/> that doesn't work. In .NET there's a server function called Server.HtmlDecode that I would use to fix something like this. Does Apex have an equivalent method? Thanks!

 

Class Code:

 

    public List<String> RecListNL 
    {
        get 
        {
	List<String> RecordList = new List<String>();			
	RecordList.add('Record #1\n\nNew Line Test');
	RecordList.add('Record #2\n\nNew Line Test');
	RecordList.add('Record #3\n\nNew Line Test');
	RecordList.add('Record #4\n\nNew Line Test');
	RecordList.add('Record #5\n\nNew Line Test');
         return RecordList;
        }
        set;    
    }  

    public List<String> RecListBR 
    {
        get 
        {
	List<String> RecordList = new List<String>();			
	RecordList.add('Record #1<br /><br />New Line Test');
	RecordList.add('Record #2<br /><br />New Line Test');
	RecordList.add('Record #3<br /><br />New Line Test');
	RecordList.add('Record #4<br /><br />New Line Test');
	RecordList.add('Record #5<br />New Line Test');
         return RecordList;
        }
        set;    
    }  

 Page Code: 

 

    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!RecListNL}" var="nl">
                    <apex:column value="{!nl}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
     
         <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!RecListBR}" var="br">
                    <apex:column value="{!br}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>   
    
    </apex:form>

 

 

We are having an issue where Customer Portal users cannot see all of the cases on the account. I ran some queries and found the unseen cases were created before the Customer Portal user was enabled/created.

 

Does anyone know if this is normal? When a new Customer Portal user is enabled will no sharing records for previous or existing cases, closed or open, be inserted?

 

Also, it is unclear in the Salesforce Customer Portal Implementation Guide what the actual sharing rules for the Executive, Manager & User roles are. Can anyone explain this in detail?

 

Thank you very much.

We have an issue where we have exceeded the number of allotted roles. In my investigation I found that 3 roles get created when a contact gets enabled as a Customer Portal User on an account that doesn't have the Executive, Manager & User roles. I believe that these 3 roles get automatically generated by based on what is set up as in Setup|Customize|Customer Portal|Settings|Number of Roles per Customer Portal Account. 

 

We have a bunch of users that have never logged in that belong to many accounts. If we diable them, how can we delete the unwanted Customer Portal roles? Because these are system roles, They can not be accessed via Setup|Manage Users|Roles.

 

Thank you very much!

Hi There,

 

I am trying to fill a PageBlockTable with some Solution records but I need to include the Selected Solution Category. I realize that this is a one to many relationship from Solution to Category an that there is a Junction object called CategoryData that in turn links to CategoryNode for the Category name. How can I link to this with a SQOL query? Here's my attempt:

 

public PageReference doSearch()
{
    sql = 'SELECT Id, SolutionNumber, SolutionName, TimesUsed, CategoryData__r.CategoryNode__r.MasterLabel FROM Solution WHERE (SolutionName LIKE \'test'%\'')';
    List<sObject> L = Database.query(sql);
    return null;
}

 

 

I get this error:

 

Visualforce Error

System.QueryException: Didn't understand relationship 'CategoryData__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. 

 

Thank you!

I have created a custom page to replace the default Solutions Tab. I go to Setup | Customize | Solutions | Buttons And Links | Edit Solutions Tab. I choose override with. Many of my custom pages appear in the pick list of potenial pages but the one I created for this is not appearing in the list. Does anyone know why? Thank you.

Can someone help me with getting my test class working? What is the test class missing?

 

Here is my Class:

 

public class NICCCloneWithArtifactsController 
{
    
    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    private NI_Change_Control__c r {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}
    
    // initialize the controller
    public NICCCloneWithArtifactsController(ApexPages.StandardController controller) 
    { 
        // initialize the stanrdard controller
        this.controller = controller;
        // load the current record
        r = (NI_Change_Control__c)controller.getRecord(); 
    }
    
    // method called from the VF's action attribute to clone the Change Request
    public PageReference cloneWithArtifacts() 
    {
        
        // setup the save point for rollback
        Savepoint sp = Database.setSavepoint();
        NI_Change_Control__c newR;
        
        try 
        {
            
            // copy the change request - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
            r = [select Id, Priority__c, Request_Summary__c, Request_Details__c, Change_Type__c, Date_Required__c, Deployment_Group__c, Data_Change__c,
                  New_Custom_Script__c, Outage_Required__c, Manager_Reviewer__c, Peer_Reviewer__c, Developer_Compiler__c, Related_Servers__c, Related_Hosted_RFC__c, NI_Change_Owner__c 
                  from NI_Change_Control__c where id = :r.id];
            
            newR = r.clone(false);
            // SANDBOX =====================================================================
            //newR.RecordTypeId = '012P00000000G42';      // Full ID = 012P00000000G42IAE
            // PRODUCTION ==================================================================
            newR.RecordTypeId = '0126000000016TJ';        // Full ID = 0126000000016TJAAY                         
            newR.Change_Status__c = 'New';
            newR.Cloned__c = true;
            newR.Cloned_From__c = r.Id;
            newR.Cloned_w_Artifacts__c = true;
            
            insert newR;
            
            // set the id of the new po created for testing
            newRecordId = newR.id;
            
            // LOOP THROUGH ALL RELATED ARTIFACTS 
            for (NICC_Artifact__c artSource : [SELECT Id, Artifact_Name__c, Type__c, Description__c, Document_Link__c, Complete__c FROM NICC_Artifact__c WHERE NI_Change_Control__c = :r.id])
            {
                
                NICC_Artifact__c artNew = artSource.clone(false);
                artNew.NI_Change_Control__c = newR.id;
                
                insert artNew;
                
                List<Attachment> Attachments = new List<Attachment>();
                for (Attachment attach : [SELECT Body, BodyLength, ContentType, Description, Name FROM Attachment WHERE ParentId = :artSource.Id]) 
                {
                     Attachment newAttach = attach.clone(false);
                     newAttach.ParentId = artNew.id;
                     Attachments.add(newAttach);
                }
                
                insert Attachments;             
            
            }

        } 
        catch (Exception e)
        {
            // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
        }
        
        return new PageReference('/'+newR.id+'/e?retURL=%2F'+newR.id);
        
    }
    
}

 

Here is my Test Class:

@isTest
private class TestNICCCloneWithArtifactsController 
{
 
    static testMethod void testArtifactCloneController() 
    {
		
        // Creae a Change Request
        NI_Change_Control__c nicc = new NI_Change_Control__c();
        //SANDBOX ====================== nicc.RecordTypeId = '012P00000000G42';
        //nicc.RecordTypeId = '012P00000000G42';
       // PRODUCTION =================== nicc.RecordTypeId = '0126000000016TJ';
        nicc.RecordTypeId = '0126000000016TJ';
        nicc.Change_Steps__c = 'test';
        nicc.Date_Required__c = system.today();
        nicc.Request_Summary__c = 'Test';
        insert nicc;
 
        // create new Artifact record
        NICC_Artifact__c ar = new NICC_Artifact__c();
        ar.NI_Change_Control__c = nicc.Id;
        ar.Type__c = 'Customer Sign-off';
        ar.Document_Link__c = 'TEST';
        ar.Description__c = 'TEST';
        insert ar;

        // create an Attachment for the Artifact
        Attachment a = [Select Body from Attachment Limit 1];
        Attachment attach = new Attachment();
        //attach.BodyLength = 10;
        attach.Name = 'test.txt';
        attach.ParentId = ar.Id;
        attach.Body = a.Body;
        insert attach;                           
         
    }
 
}

 Here's the page code:

<apex:page standardController="NI_Change_Control__c"
     extensions="NICCCloneWithArtifactsController"
     action="{!cloneWithArtifacts}">
     <apex:pageMessages />
</apex:page>

 Any tips would be greatly appreciated!

 

Can anyone tell me how I can pass a variable into a LIKE statement in a SOQL query?

 

If I hardcode the search sting I get records returned:

results = (List<Solution>)[SELECT Id, SolutionNumber, SolutionName, TimesUsed FROM Solution WHERE (SolutionName LIKE '%keywordhere%')];

 

What I need to do is pass a variable in for the keyword. I tried the following code but I get an error - Error: SolutionSearch Compile Error: unexpected token: '+'

results = (List<Solution>)[SELECT Id, SolutionNumber, SolutionName, TimesUsed FROM Solution WHERE (SolutionName LIKE '%' + searchText + '%')];

 

I have this code that works but I don't like how it imprecise the returned record are that are returned:

results = (List<Solution>)[FIND :searchText IN ALL FIELDS RETURNING Solution(Id, SolutionNumber, SolutionName, TimesUsed)] [0];

 

Thank you.

 

 Here is my goal: I have a custom page for new cases. I have a custom object that contains "heads up" information on accounts called a flash. As soon as a user selects an account via the lookup icon I need to throw a modal popup that lists the messages for the selected account. I am really close to getting this to work but I need to pass the selected account name to my controller. How can I get this value? I'm thinking by id name on the apex:inputField component but I don't know how.

 

Here's the section of code:

 

<apex:pageBlockSectionItem >
    <apex:outputLabel value="* Account Name" styleClass="RequiredLabelColor"/>
    <apex:inputField id="txtAccountName" value="{!Case.AccountId}">
        <apex:actionSupport event="onchange" action="{!showFlash}" rerender="FlashMessage">
            <apex:param name="AcctNameParam" value="{!txtAccountName.value}" assignTo="{!strAccountName}"/>
        </apex:actionSupport>
    </apex:inputField>
</apex:pageBlockSectionItem>

 The value="{!txtAccountName.value}" part is a syntax error but it's how I thought it might have worked. The case record is unsaved at this moment so I cannot use {!Case.AccountId}.

 

Thank you!

Could someone help me figure out how to get 75% coverage with this trigger I created on a custome object? Thank you.

 

// TRIGGER CODE=========================================

 

trigger addArtifactTemplates on NI_Change_Control__c (after insert)
{

    if (trigger.isInsert)
    { 

        for (NI_Change_Control__c nicc : Trigger.new)
        {         

            // IF RECORD TYPE IS "Hosted_RFC"
            if (nicc.RecordTypeId == '012P00000000G42') 

            {

                NICC_Artifact__c a1 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Communication Plan');        
                insert a1;

                NICC_Artifact__c a2 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Deployment Plan');        
                insert a2;

                NICC_Artifact__c a3 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Monitoring Plan');        
                insert a3;

                NICC_Artifact__c a4 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Rollback Plan');        
                insert a4;

                NICC_Artifact__c a5 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Test Plan');        
                insert a5;

            }

        }

    }

}

 

// MY TEST CLASS ATTEMPT ==============================


@isTest
private class TestNIChangeControl
{
    static testMethod void testaddArtifactTemplates()
    {
         NI_Change_Control__c nicc = new NI_Change_Control__c (Request_Summary__c = 'Test Request Summary Text...', Date_Required__c = System.today());
         insert nicc;
        
         NICC_Artifact__c a1 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Communication Plan');        
         insert a1;

         NICC_Artifact__c a2 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Deployment Plan');        
         insert a2;

         NICC_Artifact__c a3 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Monitoring Plan');        
         insert a3;

         NICC_Artifact__c a4 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Rollback Plan');        
         insert a4;

         NICC_Artifact__c a5 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Test Plan');        
         insert a5;
               
    }
}

 

 

 

  • September 16, 2011
  • Like
  • 0

I need to have page breaks in text that I'm displaying in an apex:pageblocktable.

How can I get the text to not show the literal "<br />" tags? "\n" new line escape doesn't seem to be rendered as a <br/> tag. When I replaceAll "\n" with <br/> that doesn't work. In .NET there's a server function called Server.HtmlDecode that I would use to fix something like this. Does Apex have an equivalent method? Thanks!

 

Class Code:

 

    public List<String> RecListNL 
    {
        get 
        {
	List<String> RecordList = new List<String>();			
	RecordList.add('Record #1\n\nNew Line Test');
	RecordList.add('Record #2\n\nNew Line Test');
	RecordList.add('Record #3\n\nNew Line Test');
	RecordList.add('Record #4\n\nNew Line Test');
	RecordList.add('Record #5\n\nNew Line Test');
         return RecordList;
        }
        set;    
    }  

    public List<String> RecListBR 
    {
        get 
        {
	List<String> RecordList = new List<String>();			
	RecordList.add('Record #1<br /><br />New Line Test');
	RecordList.add('Record #2<br /><br />New Line Test');
	RecordList.add('Record #3<br /><br />New Line Test');
	RecordList.add('Record #4<br /><br />New Line Test');
	RecordList.add('Record #5<br />New Line Test');
         return RecordList;
        }
        set;    
    }  

 Page Code: 

 

    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!RecListNL}" var="nl">
                    <apex:column value="{!nl}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
     
         <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!RecListBR}" var="br">
                    <apex:column value="{!br}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>   
    
    </apex:form>

 

 

Hello - i am having issues with my attachment extention now working on my VP? please help.

 

Here is my extention code:

public class AllAttachmentsController {

 

    public AllAttachmentsController(ApexPages.StandardSetController controller) {

 

    }

 

    public List<Attachment> ATT {get;set;}

   

    public AllAttachmentsController (ApexPages.StandardController stdController) {       

        }

   

     public List<String> getAttLinks() {

        Id caseid = ApexPages.currentPage().getParameters().get('Id');

       

        List<String> attLinks = new List<String>();

        String strURL;

        String strResult ;

               

        ATT=[SELECT Id, Name FROM Attachment

             WHERE parentId = :ApexPages.currentPage().getParameters().get('Id')];

        integer j = ATT.size();

        

        for(integer i=0; i<j; i++) {                     

           

            strURL= 'https://' + ApexPages.currentPage().getHeaders().get('Host')

                + '/servlet/servlet.FileDownload?file='  + ATT[i].Id;   

            attLinks.add(strURL);   

            }

        return attLinks ;

        }       

    static testmethod void testshow()

    {

    attachment ac=new attachment();

    list<account> acc=new list<account>();

    account a=new account(name='test');

    acc.add(a);         

    ApexPages.StandardController sc = new ApexPages.standardController(ac);

    ApexPages.StandardSetController sc1 = new ApexPages.standardSetController(acc);

    AllAttachmentsController obj  = new AllAttachmentsController (sc);

    AllAttachmentsController obj1  = new AllAttachmentsController (sc1);

          

    obj.getAttLinks();

    }

 }

 and here is my VP:

<apex:page standardController="Candidate__c" extensions="AllAttachmentsController" recordSetVar="Candidate__c"  sidebar="false" showheader="false" id="candidatelist">


<style>

<!--Table Header-->
th.classhead{
width:100%;
font-size:16px;
color:black;
font-family:Verdana,Geneva,sans-serif;
}

<!--out side table-->
table.outtertable{
margin-top:0px;
margin-bottom:0px;
margin-right:50px;
margin-left:50px;
padding:3px;
border-style:solid;
border-width:3px;
border-color:#74BDE2;
background-color:#ebeff3;
}

table.innertable{
margin-top:0px;
margin-bottom:0px;
margin-right:2px;
margin-left:0px;
padding:15px;
border-style:solid;
border-width:2px;
width:100%;
border-color:#74BDE2;
background-color:#ffffff;
}

table.dottedtable{
margin-top:0px;
margin-bottom:0px;
margin-right:2px;
margin-left:0px;
padding:15px;
width:100%;
colspan:3;
background-color:#FFFFFF;
border-style:dashed;
border-width:2px;
border-color:#f1f1f1;
}


pageBlockTable.block{
background-color:#FFFFFF;
border-style:none;
border-width:1px;
border-color:#FFFFFF;
}

</style>


<!-- Image Header -->
<head>
<center><h class="margin"><a href="http://www.healthecareers.com" target="_blank"><img src="https://c.na3.content.force.com/servlet/servlet.ImageServer?id=01550000000PNYo&oid=00D500000007FIS&lastMod=1327507164000"/></a> 
</h>
</center>

</head>

<!--Start List View-->

 
  <apex:pageBlock mode="listview" >
      <apex:pageBlockTable columns="5" columnsWidth="25%" width="90%" value="{!Candidate__c}" align="center" var="c" style="block">
      <apex:column value="{!c.First_Name__c}" />
      <apex:column value="{!c.Last_Name__c}"/>
      <apex:column value="{!c.JobSeeker_Type_All__c}"/>
      <apex:column value="{!c.Years_of_exp__c}"/>
    
    
  <apex:column headerValue="Resume" >
  <a href="{!attLinks}" target="blank">CLICK ME</a>
  </apex:column>  
      
      
      </apex:pageBlockTable>
  </apex:pageBlock>




</apex:page>

 

when i click on the "View Resume" link  in my VP it gived me a weird error?

The name '%5B%5D' can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores. 

 any help would be very appriciated.

 

Niki

We are having an issue where Customer Portal users cannot see all of the cases on the account. I ran some queries and found the unseen cases were created before the Customer Portal user was enabled/created.

 

Does anyone know if this is normal? When a new Customer Portal user is enabled will no sharing records for previous or existing cases, closed or open, be inserted?

 

Also, it is unclear in the Salesforce Customer Portal Implementation Guide what the actual sharing rules for the Executive, Manager & User roles are. Can anyone explain this in detail?

 

Thank you very much.

Hi

While searching for date I am getting this error 

 

no viable alternative at character ' '

 

 

the code is 

if (StartDate != null)
      soql += ' and Start_Date__c equals ' +  myDate ;

 please help me 

thanks 

anuraj

  • October 11, 2011
  • Like
  • 0

Hi There,

 

I am trying to fill a PageBlockTable with some Solution records but I need to include the Selected Solution Category. I realize that this is a one to many relationship from Solution to Category an that there is a Junction object called CategoryData that in turn links to CategoryNode for the Category name. How can I link to this with a SQOL query? Here's my attempt:

 

public PageReference doSearch()
{
    sql = 'SELECT Id, SolutionNumber, SolutionName, TimesUsed, CategoryData__r.CategoryNode__r.MasterLabel FROM Solution WHERE (SolutionName LIKE \'test'%\'')';
    List<sObject> L = Database.query(sql);
    return null;
}

 

 

I get this error:

 

Visualforce Error

System.QueryException: Didn't understand relationship 'CategoryData__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. 

 

Thank you!

Hi,

 

Can anyone help me with this simple query?

 

When I hard code the WhatId it works perfectly - here's the code...

 

Account acc =  [Select Id, PersonContactId, IsPersonAccount, Primary_Service__r.Name, Primary_Service__r.Id, Source_of_Data__c, Reason_for_Contact__c, People_Status__c, PersonMailingStreet, PersonMailingCity, PersonMailingState , PersonMailingPostalCode, PersonMailingCountry, PersonMobilePhone, PersonHomePhone, Gender__c, Age__c, DOB_Estimated__c, Marital_Status__c, Commitment_Type__c, Commitment_Date__c From Account where Id =  limit 1];

 However, I want it to be (unsurprisingly) dynamic. I thought something like this should work:

 

for(Task task : trigger.new){
		
		


		//Id wId = task.WhatId;
		Account acc =  [Select Id, PersonContactId, IsPersonAccount, Primary_Service__r.Name, Primary_Service__r.Id, Source_of_Data__c, Reason_for_Contact__c, People_Status__c, PersonMailingStreet, PersonMailingCity, PersonMailingState , PersonMailingPostalCode, PersonMailingCountry, PersonMobilePhone, PersonHomePhone, Gender__c, Age__c, DOB_Estimated__c, Marital_Status__c, Commitment_Type__c, Commitment_Date__c From Account where Id = task.WhatId  limit 1];


		task.Primary_Service__c = acc.Primary_Service__r.Name;
			task.Primary_Service_ID__c = acc.Primary_Service__r.Id;
			task.Source_of_Data__c = acc.Source_of_Data__c;
			task.Reason_for_Contact__c = acc.Reason_for_Contact__c;
			task.People_Status__c = acc.People_Status__c;
			task.Street__c = acc.PersonMailingStreet;
			task.City__c = acc.PersonMailingCity;
			task.State__c  = acc.PersonMailingState;
			task.PostCode__c = acc.PersonMailingPostalCode;
			task.Country__c = acc.PersonMailingCountry;
			task.Mobile__c = acc.PersonMobilePhone;
			task.Home_Phone__c = acc.PersonHomePhone;
			task.Gender__c = acc.Gender__c;
			task.Age__c = acc.Age__c;
			task.DOB_Estimated__c = acc.DOB_Estimated__c;
			task.Marital_Status__c = acc.Marital_Status__c;
			task.Commitment_Type__c = acc.Commitment_Type__c;
			task.Commitment_Date__c = acc.Commitment_Date__c;

	}

 Sorry, I left the hardcoded Id out of the first example but I'm sure you get the idea.

 

Why does a hard coded Id work and a bind variable not work?

 

Thanks in anticipation.

 

Ian

Can anyone tell me how I can pass a variable into a LIKE statement in a SOQL query?

 

If I hardcode the search sting I get records returned:

results = (List<Solution>)[SELECT Id, SolutionNumber, SolutionName, TimesUsed FROM Solution WHERE (SolutionName LIKE '%keywordhere%')];

 

What I need to do is pass a variable in for the keyword. I tried the following code but I get an error - Error: SolutionSearch Compile Error: unexpected token: '+'

results = (List<Solution>)[SELECT Id, SolutionNumber, SolutionName, TimesUsed FROM Solution WHERE (SolutionName LIKE '%' + searchText + '%')];

 

I have this code that works but I don't like how it imprecise the returned record are that are returned:

results = (List<Solution>)[FIND :searchText IN ALL FIELDS RETURNING Solution(Id, SolutionNumber, SolutionName, TimesUsed)] [0];

 

Thank you.

 

Brand new brand new with apex triggers here. I am wanting to create a trigger with lead convert that creates a new contact role when a lead is converted using the newly created contact as the primary contact and making the role "other". I've modified some code provided by Jeff Douglas. I think it will work, but the simplest part--making the role to "other" is giving me trouble. Realized I can't just put quotes around it. Can anyone help with the second to last line of code??

 

Also, if there is anything that makes it look like this won't work, could you give me a hand and let me know?

 

trigger LeadConvert on Lead (after update) {
 
  // no bulk processing; will only run from the UI
  if (Trigger.new.size() == 1) {
 
    if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {
 
      // if a new opportunity was created
      if (Trigger.new[0].ConvertedOpportunityId != null && Trigger.new[0].ConvertedContactId != null) {
            Opportunity opp = [Select o.Id from Opportunity o Where o.Id = :Trigger.new[0].ConvertedOpportunityId];
            Contact c = [Select c.Id From Contact c Where c.Id = :Trigger.new[0].ConvertedContactId];           
        
            // add an opportunity contact role
            OpportunityContactRole ocr = new OpportunityContactRole();
            ocr.OpportunityId = opp.Id;
            ocr.ContactId = c.Id;
            ocr.IsPrimary = True;
//This next line doesn't work. It's a picklist value, what syntax do I use?
//ocr.Role = "Other"
            insert ocr;
         
      }         
 
    }
 
  }     
 
}



Hi Friends,

 

I am importing account records from csv file to salesforce.I am importing 6 account records,5 records are inserted properly and the sixth one gave me an error which is :-

 

Required fields are missing [name].

 

What does the above mentioned error means?

 

Thanks,Trick009

 

 

 

  • October 01, 2011
  • Like
  • 0

 Here is my goal: I have a custom page for new cases. I have a custom object that contains "heads up" information on accounts called a flash. As soon as a user selects an account via the lookup icon I need to throw a modal popup that lists the messages for the selected account. I am really close to getting this to work but I need to pass the selected account name to my controller. How can I get this value? I'm thinking by id name on the apex:inputField component but I don't know how.

 

Here's the section of code:

 

<apex:pageBlockSectionItem >
    <apex:outputLabel value="* Account Name" styleClass="RequiredLabelColor"/>
    <apex:inputField id="txtAccountName" value="{!Case.AccountId}">
        <apex:actionSupport event="onchange" action="{!showFlash}" rerender="FlashMessage">
            <apex:param name="AcctNameParam" value="{!txtAccountName.value}" assignTo="{!strAccountName}"/>
        </apex:actionSupport>
    </apex:inputField>
</apex:pageBlockSectionItem>

 The value="{!txtAccountName.value}" part is a syntax error but it's how I thought it might have worked. The case record is unsaved at this moment so I cannot use {!Case.AccountId}.

 

Thank you!

Hi Friends,

 

 

I am trying to extract records from salesforce through the data loader

All I want to do is to extract contacts fromn a  particular record type and on a particular date.

 

So I am doing

 

select * from contacts where record type = 'some number' and  createddate=2011-9-29.

 

But I get an error  saying that createddate has to of type datetime and should not have quotes enclosed to it.

 

I am supplying date type value and am not enclosing in quotes them why am I getting an error.

 

Please tell me the right way to extract contact records based on date and recordtype.

 

Thanks,

Trick009

 

 

 

 

 

 

 

 

 

  • October 01, 2011
  • Like
  • 0

Could someone help me figure out how to get 75% coverage with this trigger I created on a custome object? Thank you.

 

// TRIGGER CODE=========================================

 

trigger addArtifactTemplates on NI_Change_Control__c (after insert)
{

    if (trigger.isInsert)
    { 

        for (NI_Change_Control__c nicc : Trigger.new)
        {         

            // IF RECORD TYPE IS "Hosted_RFC"
            if (nicc.RecordTypeId == '012P00000000G42') 

            {

                NICC_Artifact__c a1 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Communication Plan');        
                insert a1;

                NICC_Artifact__c a2 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Deployment Plan');        
                insert a2;

                NICC_Artifact__c a3 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Monitoring Plan');        
                insert a3;

                NICC_Artifact__c a4 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Rollback Plan');        
                insert a4;

                NICC_Artifact__c a5 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Test Plan');        
                insert a5;

            }

        }

    }

}

 

// MY TEST CLASS ATTEMPT ==============================


@isTest
private class TestNIChangeControl
{
    static testMethod void testaddArtifactTemplates()
    {
         NI_Change_Control__c nicc = new NI_Change_Control__c (Request_Summary__c = 'Test Request Summary Text...', Date_Required__c = System.today());
         insert nicc;
        
         NICC_Artifact__c a1 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Communication Plan');        
         insert a1;

         NICC_Artifact__c a2 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Deployment Plan');        
         insert a2;

         NICC_Artifact__c a3 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Monitoring Plan');        
         insert a3;

         NICC_Artifact__c a4 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Rollback Plan');        
         insert a4;

         NICC_Artifact__c a5 = new NICC_Artifact__c(NI_Change_Control__c = nicc.Id, Type__c = 'Test Plan');        
         insert a5;
               
    }
}

 

 

 

  • September 16, 2011
  • Like
  • 0