• Sgt_Killer
  • NEWBIE
  • 75 Points
  • Member since 2013

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 23
    Replies

I'm trying to write what I think is a really simple trigger: I want to change the contact field "2013 Clinician" if certain criteria are met in a related task. Below is my code: it doesn't have any compile errors but it also just plain doesn't work. 

 

Thank you!

 

trigger updateConsTask on Task (after update, after insert)
{

Map<Id, Contact> consMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
    for (Task tk: Trigger.new)
    {
    Ids.add(tk.WhoId);
    }
Map<id, Contact> consMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
    for (Task t: Trigger.new)
    if (t.WhoId != null && t.Status == 'Cultivate')
    {
    Contact c = consMap2.get(t.WhoId);
    c.X2013_Clinician__c = t.Clinician__c;
    
    consMap.put(c.id,c);
    }
    }

 

Hello,

 

I am working on developing a tabbed page in Visualforce but would like to know which tab the user is viewing.  If there is a way to determine this, I can cut a lot of code and buttons from the page view.

 

Anyone have a suggestion or a fast code example?

 

Thanks

Hi

 

On a VF page that produces a pdf report I have a multiselect list of users that i want to default to the logged in user if they have a particular profile, however, i am getting the error "Attempt to dereference a null object" on the following line:

 

surveyor.add(userinfo.getUserId());

 

The code im using is below, grateful for any pointers where im going wrong.

 

VF:

 

<apex:selectList id="Surveyors" size="1" title="Surveyor" value="{!surveyor}" multiselect="true" style="height:107px">
            <apex:selectOptions value="{!Surveyors}"></apex:selectOptions>
</apex:selectList> 

 Apex:

    public List<String> surveyor;
    public List<String> getSurveyor()
    {
        List<Profile> profile = [Select id,Name from Profile Where Id=:userinfo.getProfileId() limit 1];
            string userProfile = profile[0].Name;
            if(userProfile == 'Surveyor')
            {
                surveyor.add(userinfo.getUserId());
            }
        return surveyor;
    }

 

 

  • August 16, 2013
  • Like
  • 0

Hello ,

 

I am very new to Apex code and I am facing difficulties in my unit test code. The main functionality of the trigger is to assign a standard campaign to the leads based on the lead hub score. I wrote a unit test the code and it is as follows

 

@istest
public class LeadCampaignTestClass{
private static testMethod void testclass1 () {
//Create one campaign record
Campaign ca = new Campaign(Name='Test Campaign');
//required fields
insert ca;
// create a lead record
Lead le = new lead();
//required fields
le.hub_spot_score__c = 25;
insert le;
// adding a campaign member
List<CampaignMember> members = [SELECT Id FROM CampaignMember
WHERE LeadId
= :le.Id AND CampaignID = :ca.Id];
System.assertEquals(1, members.size());
}
// Negative test class
private static testMethod void testclass2(){
//Create one campaign record
Campaign ca = new Campaign(Name='Test Campaign');
insert ca;
//create lead record
Lead le = new lead();
//No hub score is added
insert le;
List<CampaignMember> members = [SELECT Id FROM CampaignMember WHERE LeadId
= :le.Id AND CampaignID = :ca.Id];
System.assertEquals(1, members.size());
}
}

 

 

When I tried to run the test , the foowing error was displayed :

 

Apex Test Result Detail  

Time Started 8/20/2013 10:44 AM Class LeadCampaignTestClass Method Name testclass2 Pass/Fail Fail Error Message System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName, Company]: [LastName, Company] Stack Trace

Class.LeadCampaignTestClass.testclass2: line 27, column 1

 

 

Can some one help me with this issue asap .

 

Regards,

Angela Joseph



public with sharing class ComplaintInquiriesHandler { private boolean isExecuting = false; private integer batchSize = 0; public ComplaintInquiriesHandler(boolean triggerIsExecuting, integer size){ isExecuting = triggerIsExecuting; batchSize = size; } public void OnBeforeUpdate(Complaint_Inquiries__c[] oldComp, Complaint_Inquiries__c[] updatedComp){ For(Complaint_Inquiries__c Compl:updatedComp) { if (Compl.Copy_From_Account__c == true){ list<Account> Acc = [Select id,BillingStreet from Account where Name=:Compl.Business_Name__c limit 1]; if(Acc!=null){ Compl.Business_Address__c = Account.BillingStreet; } Compl.Copy_From_Account__c = false; } } } }

 Could someone please assist? I am not able to figure out the issue here.

  • August 20, 2013
  • Like
  • 0

Hi, I have a requirement for a visualforce page where, I need a number of identical forms to display depending on what # is entered into a text box.

Say for instance there is a form with the fields: Item_Name, Item_Description,Item_Number.

And then say the user wants to enter multiple items without switching to a new page everytime, so they go to a little inputText and enter "5", and click the button beside it.

Is there a way to display that initial form 5-times on the same page. 

 

Would I use Apex:repeat of some sort? If anyone could point me in the right direction I would very much appreciate it.

 

Cheers

 

 

 

Hi guys,

I need opinion on how I can achieve the required functionality.

I have a custom object A that stores user progress details every month. When a new record is added next month I want to copy user’s previous month’s scorer to newly added record. I nut shall I want to have users previous month’s score into the current month record in custom field.

 

Am I right to think that I need before insert trigger to achieve it. But don’t know how I can save previous month’s score in the trigger temporarily and then added to new record. Any help?

 

Thanks,

Hi,

 

I have field on the object in which users have to enter Time and date manually.Now we want to replace that field with date and time field so that instead of typing  date and time manualy they can select date and time.

 

If we delete this field

 

1) What will happen to the existing data associated to the field.

 

What do you think are my options?What are your sugestions?.How Shall I proceed.

 

Please advise.

Thanks

 

  • August 19, 2013
  • Like
  • 0

I am having a view state error on my vf page.

Below the controller code which i believe is causing the eror. Can anyone help me which part of the code is causing this error

 

public class Team_Attach_ACL
{
    id accountid,rectypeid;
    public AccountProgramAttachment__c naObj{set; get;}
   public Attachment attachment1{set; get;}
    public string filename { get;set;}
    public Team_Attach_ACL(ApexPages.StandardController controller)
    {
        accountid=system.currentPageReference().getParameters().get('id');
        naObj=new AccountProgramAttachment__c();
        naObj.isactive__c=true;
        Attachment1=new Attachment();
        rectypeid=Schema.SObjectType.AccountProgramAttachment__c.getRecordTypeInfosByName().get('Attachments').getRecordTypeId();     
    }
   public Pagereference upload()
    {       
        Attachment1.name = filename;
        naObj.name__c=filename;
        naObj.accountId__c=accountid;
        naObj.AttachmentCategory__c=naObj.AttachmentCategory__c;
        naObj.AttachmentTitle__c=attachment1.name;
        naObj.recordtypeid=rectypeid;
        naObj.IsActive__c = naObj.IsActive__c;
        if(filename!=null)
        {
            try
            {      
                insert naObj;
                Attachment1.ParentId = naObj.id;
                insert Attachment1;
                return (new Pagereference('/'+accountid));  
            }
            catch(Exception ex1)
            {
                //delete naObj;
                return null;
            }
        }
        else
        {
            String message1 = Label.AttachmentFileNotChosen;
            Apexpages.addmessage(new ApexPages.Message(ApexPages.severity.FATAL, message1));
        }  
        return null;
    }
   public Pagereference cancel()
    {
        return (new Pagereference('/'+accountid));
    }
}

I'm trying to write what I think is a really simple trigger: I want to change the contact field "2013 Clinician" if certain criteria are met in a related task. Below is my code: it doesn't have any compile errors but it also just plain doesn't work. 

 

Thank you!

 

trigger updateConsTask on Task (after update, after insert)
{

Map<Id, Contact> consMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
    for (Task tk: Trigger.new)
    {
    Ids.add(tk.WhoId);
    }
Map<id, Contact> consMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
    for (Task t: Trigger.new)
    if (t.WhoId != null && t.Status == 'Cultivate')
    {
    Contact c = consMap2.get(t.WhoId);
    c.X2013_Clinician__c = t.Clinician__c;
    
    consMap.put(c.id,c);
    }
    }

 

Hello,

 

I am working on developing a tabbed page in Visualforce but would like to know which tab the user is viewing.  If there is a way to determine this, I can cut a lot of code and buttons from the page view.

 

Anyone have a suggestion or a fast code example?

 

Thanks

Hi

 

On a VF page that produces a pdf report I have a multiselect list of users that i want to default to the logged in user if they have a particular profile, however, i am getting the error "Attempt to dereference a null object" on the following line:

 

surveyor.add(userinfo.getUserId());

 

The code im using is below, grateful for any pointers where im going wrong.

 

VF:

 

<apex:selectList id="Surveyors" size="1" title="Surveyor" value="{!surveyor}" multiselect="true" style="height:107px">
            <apex:selectOptions value="{!Surveyors}"></apex:selectOptions>
</apex:selectList> 

 Apex:

    public List<String> surveyor;
    public List<String> getSurveyor()
    {
        List<Profile> profile = [Select id,Name from Profile Where Id=:userinfo.getProfileId() limit 1];
            string userProfile = profile[0].Name;
            if(userProfile == 'Surveyor')
            {
                surveyor.add(userinfo.getUserId());
            }
        return surveyor;
    }

 

 

  • August 16, 2013
  • Like
  • 0

idstring= apexpages.currentpage().getparameters().get('recordid');
 requestStatus =apexpages.currentpage().getparameters().get('request');
 } 
 Public pagereference ChangeAccount(){
 try{
List<string> recordIdList= idstring.split(',');
info=[select id,accountid__c,contactid__c,status__c,rejected__c from CompanyRequestInfo__c  where id in: recordIdList];

Hi,

 

We have added some validation rules to some of the fields. But when any validation fails, that error message gets displayed at the top of VF page with appended field lables at the start of error message.

 

For e.g If validation error message is added as Is manadatory then the error message displays that like Name: is manadation where Name is the field lable.

I want to remove this field lable from being appended to message, any help to edit these page messages before displaying on VF.

 

Thanks.

Hi All,

 

I have created buttons on a case record type to create child cases when pressed with an app called object converter.  I am looking for  way to show that the button has been pressed and only allow each button to be pressed once.  Please let me know if you have a solution for this issue.

 

Thanks,

hello.  odd behavior.  i have a vf page which allows the user to upload an attachment (standard inputFile stuff).  the attachment area is displayed conditionally - based on a controller variable.  when i browse to the page and try to upload an attachment, i get an error:  REQUIRED_FIELD_MISSING, Required fields are missing: [File Name, Body]: [File Name, Body].  However if i remove the "rendered" flag from the outputPanel, it works correctly.  what am i doing wrong?  all info is below.  thanks so much for your time.

 

thanks

chris 

 

the code is pasted below.  i tried to remove all unnecessary code...

 

VF Page is below.  offending "rendered" attribute in bold italics.  when the user clicks "CLICK ME", it calls the controller and flips the flag so that the inputFile area is displayed:

 

<apex:form >

<apex:outputPanel id="fullPagePanel">
<table >
<tr>

<td width="25%" valign="top">
<apex:outputPanel id="leftTablePanel">
<table >
<apex:actionRegion >
<apex:repeat value="{!itemWrapList}" var="itemWrap" id="itemWrapListRepeat">
<tr>
<td width="20%">
<apex:outputLink value="#">CLICK ME
<apex:actionSupport event="onclick" action="{!selectItemForEdit}" rerender="leftTablePanel, detailsPanelOuter, controllerMessagePanel, attachmentOuterPanel">
<apex:param name="selectedItemId" value="{!itemWrap.tmpId}" assignTo="{!itemIdForEdit}"/>
</apex:actionSupport>
</apex:outputLink>
</td>
</tr>
</apex:repeat>
</apex:actionRegion>
</table>
</apex:outputPanel>

<apex:outputPanel id="attachmentOuterPanel">
<apex:outputPanel id="attachmentPanel" rendered="{!AND(itemWrapForEdit != null, itemWrapForEdit.item.Id != null)}">
<apex:actionRegion >
<apex:outputText value="Input File: "/><apex:inputFile value="{!attachmentObj.body}" filename="{!attachmentObj.name}"/><br/>
<apex:commandButton value="Upload" action="{!upload}"/>
</apex:actionRegion>
</apex:outputPanel>
</apex:outputPanel>
</td>

</tr>
</table>
</apex:outputPanel>

</apex:form>

 

Apex below - upload function.  with the "rendered" attribute present, the attachmentObj is always empty, but without the "rendered" attribute, it works correctly:

 

 

public void upload() {
attachmentObj.ParentId = 'a0rM0000000KrVT';
insert attachmentObj;
attachmentObj = new Attachment();
return;
}

 

more Apex - selectItemForExit - which is what toggles the flag so that the inputFile is rendered...

public void selectItemForEdit() {
controllerMessage = null;
System.Debug(' #### in selectItemForEdit:'+itemIdForEdit);
if (itemIdForEdit != null) {
for (ItemWrapClass wrap : itemWrapList) {
System.Debug(' #### wrap.tmpId:'+wrap.tmpId);
if (itemIdForEdit == wrap.tmpId) {
// found
wrap.currentItemFlag = true;
itemWrapForEdit = wrap;

} else {
wrap.currentItemFlag = false;
}

}
}
System.Debug(' #### itemWrapForEdit:'+itemWrapForEdit);
}