• NikiG22
  • NEWBIE
  • 200 Points
  • Member since 2011

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 76
    Replies

Hello - I am trying to update the Unitprice on the opportuntiylineitem when a discount is added/removed on the opportuntiy. I have code here but it is not working. Any help would be greatly appriciated!!!

 

The Opportuntiy discount field is called "Ad_Agency_Discount__c". 

 

 

trigger AgencyDiscount on Opportunity (after update) {

List<Opportunity> discopps=new List<Opportunity>();

for (Opportunity opp : trigger.new)
   {
       Opportunity discOpp=trigger.oldMap.get(opp.id);
       if  (opp.Ad_Agency_Discount__c >0.00)

       {
          discopps.add(opp);
       }
   }
   if (!discopps.isEmpty())

{
List<OpportunityLineItem> olis = [SELECT ID,UnitPrice ,OpportunityLineItem.opportunity.Ad_Agency_Discount__c,Opp_Agency_Discount__c FROM OpportunityLineItem WHERE OpportunityId in :discopps];



List<Opportunity> opps=new List<Opportunity>();
for (OpportunityLineItem OLupdisc: olis)
{

For (integer i = 0; i < OLupdisc.opportunity.Ad_Agency_Discount__c; i++){

OpportunityLineItem newUnitPrice = new OpportunityLineItem ();
newUnitPrice.unitprice = OLupdisc.unitprice-(OLupdisc.unitprice *OLupdisc.opportunity.Ad_Agency_Discount__c);

 update OLupdisc;

}

}

}
}

 

 

Thank you, 

Niki

Hello - I am trying to calculate the number of business hours it took for one of my data analsys to triage a new Regestration (account), i need to have business hours between 7:00 am to 6:00pm and excluding weekends. 

 

Any help would be AWESOME!

 

Cheers,

Niki

Hello - I have a custom object called a Sectacular__c that is located on the OpportutiyLineItem.

 

I need to roll up the count of all the Products (opportutniyLineItems) the Spectatular has.

 

I have gotten the following error but can not figure out the issue:

Error	Error: Compile Error: Didn't understand relationship 'OpportunityLineItem' in FROM part of query call. 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. at line 10 column 30

 

 

Here is my code:

trigger OppLineItmRollup on Spectacular__c (after insert,after update)
{
   
  Set<id> RollChilSet  = new Set<id>();
  List<Spectacular__c> updateList = New List<Spectacular__c>();
  for(OpportunityLineItem rollUpchild :trigger.new){
      RollChilSet.add(rollUpchild.Spectacular__c); 
  }

   for(Spectacular__c rolPar:[select id,Sponsorships_Sold__c,Sold_Amount__c,(select id, UnitPrice, Quantity, Spectacular__c FROM OpportunityLineItem) FROM Spectacular__c where id IN:RollChilSet]) {
  decimal totalval = 0;  
 
    for(OpportunityLinrItem rol : rolPAr.OpportuntityLineItem){
    totalval = totalval  + rol.Quantity;
   
     }  

    rolPa.Sponsorships_Sold__c = totalval ;
    updateList.add(rolPar);

    }

   update updateList;

 }

 Please help.

Niki

Hello - I have a trigger that inserts a task in my opportunity when the opp is cloosed won. Now i need to eclude users with a role = inside sales. i have it in there but it is not working?

 

Also - i need help bringing my code up to 100%

 

any help would be awesome. Thank you

 

public class TasksForOpportunitiesClosedToContracts 
{
    public static void createTasksForOpportunityClosedToContract(Opportunity[] opportunities)
    {
        RecordType RecType = new RecordType();  
        RecType = [SELECT ID FROM RecordType WHERE Name = 'SAM Task'];
        

        for (Integer i = 0; i < opportunities.size(); i++) 
        {
            IF (opportunities[i].StageName == 'Closed Won' &&
                opportunities[i].LeadSource != 'Purchased from Site' &&
                opportunities[i].Message_Sent__c == false &&
                opportunities[i].Owner.UserRole.Name !='Inside Sales Representative'&&
                opportunities[i].Count_of_Pending_RS__c==0) 
            {
                Account acct = new Account();
                Task newContractTask = new Task();                
                
                acct = [SELECT client_id__c FROM Account WHERE ID = :opportunities[i].AccountId];
                                
                newContractTask.client_id__c = acct.client_id__c;
                newContractTask.OwnerID = opportunities[i].Account_Manager__c;
                newContractTask.Subject = 'New Closed Won Opportunity';
                newContractTask.Description = opportunities[i].Description;
                newContractTask.WhatID = opportunities[i].ID;
                newContractTask.Status = 'Not Started';
                newContractTask.RecordTypeID = RecType.ID;
                newContractTask.Priority = 'High';
                newContractTask.Type = 'New Closed Won Opportunity';
                newContractTask.ActivityDate = system.today();
                newContractTask.reminderdatetime = system.now();
                newContractTask.isreminderset = false;
                newContractTask.Short_Description__c = 'Create Contract/ Activate Job';
    
                insert newContractTask;

                
            } 
            
        } 
      } 
    
    static testMethod void test_trTasksForOpportunitiesToContracts()
    {
        Opportunity candidateOpportunity = [Select opp.StageName, opp.LeadSource From Opportunity opp 
                                            where opp.StageName != 'Closed Won' 
                                            and opp.StageName != 'Closed Lost' 
                                            and opp.Billing_is_different_than_Account__c = false 
                                            LIMIT 1];
        candidateOpportunity.StageName = 'Closed Won';
        candidateOpportunity.Billing_Email__c = 'test@healthecareers.com';
        candidateOpportunity.Billing_Contact__c = 'Test Contact' ;
        candidateOpportunity.Invoice_Delivery_Method__c = 'Email';
        candidateOpportunity.Payment_Method__c = 'Invoice';
        candidateOpportunity.Billing_Contact__c = 'Test Contact' ;
        candidateOpportunity.Type = 'Renewal';
        candidateOpportunity.New_Dollar_Amount__c =0;
        candidateOpportunity.Win_Loss_Notes__c = 'These are test notes.';
        update candidateOpportunity;
        
        Task newContractTask = [select Type from Task where WhatId = :candidateOpportunity.Id and Subject = 'New Closed Won Opportunity' LIMIT 1];
        System.assertEquals('New Closed Won Opportunity', newContractTask.Type);
        
    }
    
    
}

 

I have a page redirect/Save controller and need help wrighting a test class for it.  I have 19% covered right now and need 100%

 

Any help would be appriciated

Niki

 

Controller and Test:

public class mywebLeadController {
    Lead lead;

    public Lead getLead() {
        if(lead == null) lead = new Lead();
        return lead;
    }

    public PageReference savelead() {
        // Add the lead to the database. 
        insert lead;
        
        // Send the user to the landing page for the new lead.
        PageReference leadPage = page.WebLeadLandingPage;
        leadPage.setRedirect(true);
        return leadPage;
    }
    
   
   
    @IsTest static void testSave() { 
            
    Lead lead = new Lead ();
    mywebLeadController pjae = new mywebLeadController (); 
            
    Lead.FirstName = 'Test';
    Lead.LastName = 'Test';
    Lead.Company = 'OTJ - NG';
    Lead.Email = 'test@otj.com';
    
    insert lead;
    
    PageReference leadPage = page.WebLeadLandingPage;
    leadPage.setRedirect(true);
    
    System.debug('the current page is...' +ApexPages.currentPage() );
       
    
    }
}//End

 

Hello - I need help with building a GIUD (UUID) in SFDC? we are revamping our integration with our IT department and they want me to build a GUID in SFDC. I have never done this and have no idea where to start. I have found some sample code and this dosent work?

 

global class guidGenerator {

    private static String kHexChars = ’0123456789abcdefABCDEF’;

    global static String generateGUID(){

        String returnValue = ”;
        Integer nextByte = 0;
        for(Integer i = 0; i &lt; 16; i++){
            if(i==4 || i==6 || i==8 || i==10){
                returnValue += ‘-’;
            }
            
            nextByte = (Math.round(Math.random() * 255)-128) &amp; 255;

            if(i==6){
                nextByte = nextByte &amp; 15;
                nextByte = nextByte | (4 &lt;&gt; 4);
            returnValue += charAt(kHexChars,nextByte &amp; 15);
        }
        return returnValue;
    }

    public static String charAt(String str, Integer index){
        if(str == null){
            return null;
        }
        if(str.length() &lt;= 0){
            return str;    
        }
        if(index = str.length()){
            return null;    
        }
        return str.substring(index, index+1);
    }
}

 

ANY help would be much appriciated.

 

Thank you!

NIki

  • September 14, 2012
  • Like
  • 0

Can anyone help me move my coverage for this trigger to a higher %? any help is appriciated.

 

Lines not Covered

:

trigger trg_new_AdProductFulfillment on Opportunity (after update)
{
   List<Opportunity> closedWonOpps=new List<Opportunity>();

   for (Opportunity opp : trigger.new)
   {
       Opportunity oldOpp=trigger.oldMap.get(opp.id);
       if ( (opp.StageName=='Closed Won') &&
            (oldOpp.StageName!='Closed Won')&&
            (opp.Message_Sent__c== False))
       {
          closedWonOpps.add(opp);
       }
   }
    
   if (!closedWonOpps.isEmpty())
   {
    List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportuntiy_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True' and
        OpportunityId in :closedWonOpps];

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   for (OpportunityLineItem oli : olis)
   {
    
    For (integer i = 0; i < oli.Quantity; i++){
            Ad_Product_Fulfillment__c newaf= new Ad_Product_Fulfillment__c();
            newaf.Opportunity__c = oli.Opportunityid;
            newaf.Placement__c = oli.Standard_RateproductID__c;
            newaf.Account__c = oli.Account_ID__c;
            newaf.IO_Start_Date__c = oli.Closed_Won_Date__c;
            newaf.PO_IO_Number__c = oli.PO_IO_Number__c;
            newaf.Quantity__c = oli.Quantity;
            newaf.Expiration_Date__c = oli.Closed_Won_Date__c +365;
            newaf.Account_Executive__c = oli.Opportuntiy_Owner_id__c;
            newaf.Account_Manager__c = oli.Account_Manager_ID__c;
            afToInsert.add(newaf);
       }
          }

    insert afToInsert;
   }
}

 

 

Here is my Test Class:

@isTest(SeeAllData=True)

Public class Testtrg_new_AdProductFulfillment{

static testmethod void Testtrg_new_AdProductFulfillment()

{


List<Opportunity> closedWonOpps=new List<Opportunity>();

Opportunity opp = new Opportunity();
opp.StageName='Closed Won';
opp.Message_Sent__c= False;
opp.Name = 'Test';
opp.Account_Manager__c = '00550000000saAA';
opp.CloseDate =Date.newInstance(2012, 01, 15);
opp.Product_Interest__c = 'Job Posting';
opp.Billing_Email__c = 'test@otj.com';
opp.New_Dollar_Amount__c=100;
insert opp;

       {
          closedWonOpps.add(opp);
       }

List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportuntiy_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True'and
        OpportunityId in :closedWonOpps];
        
OpportunityLineItem oppt = new OpportunityLineItem();
oppt.OpportunityId=opp.Id;
oppt.Quantity =1;
oppt.Cost_Type__c ='weekly';
oppt.TotalPrice =100;
oppt.PricebookEntryId='01u50000003SHVz';
insert oppt;

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   {
Ad_Product_Fulfillment__c adg= new Ad_Product_Fulfillment__c();
            adg.Opportunity__c = '006W0000002VxWF';
            adg.Placement__c = '01t50000001YRdD';
            adg.Account__c = '001W0000004yqYJ';
            adg.IO_Start_Date__c = Date.newInstance(2012, 01, 15);
            adg.PO_IO_Number__c = '123';
            adg.Quantity__c = 1;
            adg.Expiration_Date__c = Date.newInstance(2012, 01, 15);
            adg.Account_Executive__c = '00550000000saAA';
            adg.Account_Manager__c = '00550000000saAA';
insert afToInsert;
}

}}

 Please help!

 

Thank you

Niki

Can anyone help with the test coverage on this trigger? I am terrable with test classes.

 

trigger trg_new_AdProductFulfillment on Opportunity (after update)
{
   List<Opportunity> closedWonOpps=new List<Opportunity>();

   for (Opportunity opp : trigger.new)
   {
       Opportunity oldOpp=trigger.oldMap.get(opp.id);
       if ( (opp.StageName=='Closed Won') &&
            (oldOpp.StageName!='Closed Won')&&
            (opp.Message_Sent__c== False)) 
       {
          closedWonOpps.add(opp);
       }
   }
    
   if (!closedWonOpps.isEmpty())
   {
    List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportunity_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True' and
        OpportunityId in :closedWonOpps];

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   for (OpportunityLineItem oli : olis)
   {
    
    For (integer i = 0; i < oli.Quantity; i++){
            Ad_Product_Fulfillment__c newaf= new Ad_Product_Fulfillment__c();
            newaf.Opportunity__c = oli.Opportunityid;
            newaf.Placement__c = oli.Standard_RateproductID__c;
            newaf.Account__c = oli.Account_ID__c;
            newaf.IO_Start_Date__c = oli.Closed_Won_Date__c;
            newaf.PO_IO_Number__c = oli.PO_IO_Number__c;
            newaf.Quantity__c = oli.Quantity;
            newaf.Expiration_Date__c = oli.Closed_Won_Date__c +365;
            newaf.Account_Executive__c = oli.Opportunity_Owner_id__c;
            newaf.Account_Manager__c = oli.Account_Manager_ID__c;
            afToInsert.add(newaf);
       }
          }

    insert afToInsert;
   }
}

 Thank you,

Niki

Hello - i have some code here that will automaticlly create a new line item on an object called Ad Product Fulfillment when a closed won opp has a specific product. 

 

The problem is that it is doubling the line items isted of inserting the quantity. So insted of getting 1 i get 2?

 

Please help!

trigger trg_new_AdProductFulfillment on Opportunity (after update)
{
   List<Opportunity> closedWonOpps=new List<Opportunity>();

   for (Opportunity opp : trigger.new)
   {
       Opportunity oldOpp=trigger.oldMap.get(opp.id);
       if ( (opp.StageName=='Closed Won') &&
            (oldOpp.StageName!='Closed Won')) 
       {
          closedWonOpps.add(opp);
       }
   }
    
   if (!closedWonOpps.isEmpty())
   {
    List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Opportunity_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True' and
        OpportunityId in :closedWonOpps];

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   for (OpportunityLineItem oli : olis)
   {
    
    For (integer i = 0; i < oli.Quantity; i++){
            Ad_Product_Fulfillment__c newaf= new Ad_Product_Fulfillment__c();
            newaf.Opportunity__c = oli.Opportunityid;
            newaf.Placement__c = oli.Standard_RateproductID__c;
            newaf.Account__c = oli.Account_ID__c;
            newaf.IO_Start_Date__c = oli.Closed_Won_Date__c;
            newaf.PO_IO_Number__c = oli.PO_IO_Number__c;
            newaf.Quantity__c = oli.Quantity;
            newaf.Expiration_Date__c = oli.Closed_Won_Date__c +365;
            newaf.Account_Executive__c = oli.Opportunity_Owner_id__c;
            afToInsert.add(newaf);
        }
    }

    insert afToInsert;
   }
}

 Cheers,

Niki

Hello Again - I know i really have issues with test classes. if any one has any tip sheets on the it would be awesome.

 

I need help on this Extention

Class:

public with sharing class ResumeExtension {

            List<Resume_Subscriptions__c> subscriptions { get; set; }

             public ResumeExtension( ApexPages.StandardSetController stdController ) {
               subscriptions = ( List<Resume_Subscriptions__c> ) stdcontroller.getSelected();
             
             }


            public PageReference newSave() { 

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

                        for( Resume_Subscriptions__c rs : subscriptions ) {

                             if(rs.Active__c && activeUserIds.contains( rs.User__c ) || rs.Active__c && rs.Active_Contact_RS_Count__c ==1 ) {
                             rs.Active__c = false;
                             rs.User__c.addError( 'You cannot have two active resumes with the same user. Your Changes have been saved, PLEASE CLICK DONE' );

                              } 
                             else if( rs.Active__c ) {
                             activeUserIds.add( rs.User__c );}

                       }

                       upsert subscriptions;

                        
                        return null ;   // change this to return the page you want.
                      
           }
}

 you help is much appriciated

Niki

I need help with this trigger, i need to get some coverage on it so i can deploy it to production.. please help.

 

trigger RollUp on Resume_Subscriptions__c (after update, before delete) {

    // Set to hold the IDs of the Contacts of the Subscriptions
    Set<ID> ContactIDs= new Set<ID>();
    // Set to hold the IDs of the Subscriptions
    Set<ID> SubIDs = new Set<ID>();
    // Set to hold the IDs of the Contacts where the values need to be reset
    Set<ID> ContactIDsForReset = new Set<ID>();

    if(trigger.isupdate || trigger.isInsert)
    {
        for(Resume_Subscriptions__c rsSub : trigger.new )
        {
            // If the contact of a subscription has changed, then the old contact also needs to be updated 
            if( rsSub.User__c != trigger.oldmap.get(rsSub.ID).User__c)
                if( trigger.oldmap.get(rsSub.ID).User__c != null )
                    ContactIDs.add(trigger.oldmap.get(rsSub.ID).User__c);
            if(rsSub.User__c!=null)
            {
                ContactIDs.add(rsSub.User__c);
            }
        }
        ContactIDsForReset.addAll(ContactIDs);

        // The list of Contacts where the update has to take place
        List<contact> ContactsToUpdate = new List<contact>();    

        // Querying the database to get the Number of Subscriptions under an contact and the sum of the deal values of the Subscriptions under an contact
        AggregateResult[] Subscriptionsum = [select count(ID) NoOfSubscriptions, User__c ContactID from Resume_Subscriptions__c where Active__c=true AND User__c in: ContactIDs group by User__c ];
        
        for( AggregateResult ContactDetail : Subscriptionsum )
        {
            contact ContactToUpdate = new contact(ID = (ID)(ContactDetail.get('ContactID')));
            ContactToUpdate.Active_Resumes__c = integer.valueOf(ContactDetail.get('NoOfSubscriptions'));
            ContactsToUpdate.add(ContactToUpdate);
            // The contact being handled should not be reset. Hence removing it from the ResetSet
            ContactIDsForReset.remove((ID)(ContactDetail.get('ContactID')));
        }
        
        for( ID i : ContactIDsForReset )
        {
            // Resetting the summed up values to 0 if the contact no longer has a subscription.
            contact ContactToUpdate = new contact( ID = i );
            ContactToUpdate.Active_Resumes__c = 0;
            ContactsToUpdate.add(ContactToUpdate);
        }
        
        if(ContactsToUpdate.size() > 0)
            update ContactsToUpdate;
            
        ContactsToUpdate.clear();
    }

    if(trigger.isdelete)
    {
        for(Resume_Subscriptions__c rsSub : trigger.old )
        {
            if( rsSub.User__c != null)
                ContactIDs.add(rsSub.User__c);
            SubIDs.add(rsSub.ID);
        }
        ContactIDsForReset.addAll(ContactIDs);

        // The list of Contacts where the update has to take place
        List<contact> ContactsToUpdate = new List<contact>();    
        
        // Querying the database to get the Number of Subscriptions under an contact excluding the Subscriptions being deleted
        AggregateResult[] Subscriptionsum = null;
        if(ContactIDs.size() > 0)
        {
            Subscriptionsum = [select count(ID) NoOfSubscriptions, User__c ContactID from Resume_Subscriptions__c where User__c in: ContactIDs and ID not in: SubIDs group by User__c ];

            for( AggregateResult ContactDetail : Subscriptionsum )
            {
                contact ContactToUpdate = new contact(ID = (ID)(ContactDetail.get('ContactID')));
                ContactToUpdate.Active_Resumes__c = integer.valueOf(ContactDetail.get('NoOfSubscriptions'));
                ContactsToUpdate.add(ContactToUpdate);
                // The contact being handled should not be reset. Hence removing it from the ResetSet
                ContactIDsForReset.remove((ID)(ContactDetail.get('ContactID')));
            }

            for( ID i : ContactIDsForReset )
            {
                // Resetting the summed up values to 0 if the contact no longer has a subscription.
                contact ContactToUpdate = new contact( ID = i );
                ContactToUpdate.Active_Resumes__c = 0;
                ContactsToUpdate.add(ContactToUpdate);
            }
        }
        
        if(ContactsToUpdate.size() > 0)
            update ContactsToUpdate;

        ContactsToUpdate.clear();
    }

 Thank you,

Niki

Can someone help me with adding a test class on my controller. thank you!

 

public class dataTableCon{
public Candidate__c cc{set;get;}
public list<Candidate__c> cvd{get;set;}

public dataTableCon(ApexPages.StandardController controller) {
cvd = new list<Candidate__c>();

cvd = [select Full_Name__c, JobSeeker_Type__c,Years_of_exp__c from Candidate__c ];

    }
    
   

 

Hello i have a view of all of our candidates for emplayers to see, but for some reason the list view isnt showing ALL the candidates? can anyone help?

 

Also it would be nice to add a Next and previous page..just a nice to have

 

code:

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


<style>
pageBlockTable.format{
text-color:"black";
font-family:"Times New Roman", Times, serif;
size:5;
text-align:justify;
}

</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>

<P align="center"> <font size="5"> Candidates Attending the April 10th New York City Healthcare Career Fair by <b>HEALTH</b>e<i>CAREERS</i></font></p>

<!--Start List View-->
<table align="center" width="80%">
<tr>
<td>
  <apex:pageBlock mode="listview" >
   <apex:pageBlockTable columns="4" columnsWidth="20%" width="50%" value="{!Candidate__c}" align="center" var="c" style="format">
      <apex:column headerValue="Name" value="{!c.Full_Name__c}" />
      <apex:column headerValue="Job Category" value="{!c.JobSeeker_Type__c}"/>
      <apex:column value="{!c.Years_of_exp__c}"/>
      <apex:column headerValue="View Resume"> 
      <apex:outputLink value="/apex/AttachmentsCandidateView?id={!c.id}" target="_blank">Click here</apex:outputLink>
      </apex:column>
   </apex:pageBlockTable>
  </apex:pageBlock>
</td>
</tr>
</table>


</apex:page>

 thanks,

Niki

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

Hello - I need help adding a test calss for the following controller?Please help!

 

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 ;
        }        

 }

 Cheers,

Niki

Hello -

I am having issues with validating data on my VP. I have an object called resume subscriptions that have  can be activated with one user (contact) assigned to it. So it is a one to one match. But there can not be more then 1 active resume on the user (contact).

 

the issue im facing is if the sales rep go's to my Mass edit VP they can check all 5 resume subscriptions to be active and assign them all to the same user and hit save and the page will allow all the resume subs to be active with that 1 user, in return messing up the connection to our backoffice.

 

so im looking to run some java to catch the active checkbox and see what user is being assigned, then throw an error if there are more then i resume being active with the same user. The fun part is the resume sub can be assigned to that user but not activated.

 

I have been struggling with this project for 3 weeks now so any help would be AWESOME!!!

 

here is my VP:

<apex:page standardcontroller="Resume_Subscriptions__c" recordSetVar="unused" sidebar="false">

<!--Validation Script-->
<script type="text/javascript">


</script>

<!--Start Form-->
    
<apex:includeScript value="{!$Resource.UtilJS}" />
<apex:form id="massedit">
<br/>
<font size="4px" Color="black">Resume Subscription Edit Page</font>
<apex:pageBlock >
<apex:pageMessages />

Note: All modifications made on the page will be lost if Cancel button is clicked without clicking the Save button first. 

<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>

<!--Start Edit Fields-->
<apex:pageBlockTable value="{!selected}" var="RS" id="table">

<apex:column headerValue="Resume Sub Number">
<apex:inputField value="{!RS.Name}"/>
</apex:column>
<apex:column headerValue="Product Name">
<apex:inputField value="{!RS.Product_Name__c}"/>
</apex:column>

<apex:column headerValue="Active" id="activefield" >
<apex:inputField value="{!RS.Active__c}"/>
</apex:column>
<apex:column headerValue="User" id="user">
<apex:inputField value="{!RS.User__c}"/>
</apex:column>
<apex:column headerValue="Daily View Limit">
<apex:inputField value="{!RS.Daily_View_Limit3__c}"/>
</apex:column>
<apex:column headerValue="Daliy View Limit Enforced">
<apex:inputField value="{!RS.Daily_View_Limit_Enforced__c}"/>
</apex:column>
<apex:column headerValue="Views Purchased">
<apex:inputField value="{!RS.Views_Purchased3__c}"/>
</apex:column>
<apex:column headerValue="View Remaining">
<apex:inputField value="{!RS.View_Remaining__c}"/>
</apex:column>
<apex:column headerValue="Price">
<apex:inputField value="{!RS.Price__c}"/>
</apex:column>
<apex:column headerValue="Subscription Term">
<apex:inputField value="{!RS.Subscription_Term3__c}"/>
</apex:column>
<apex:column headerValue="Purchase Date">
<apex:inputField value="{!RS.Purchase_Date2__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>

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

 

 

Hello - I am trying to discplay a link to the attachment on my custom object?

 

I have a VP discplaying Candidate information for employers to look at. at the end of the list i need to add a button or link that allows them to click on it and have the PDF version of the attachment pop-up?

 

Any idea on how to do this? any help would be very appriciated!

 

Niki

Hello -

 

I am having some issue with adding a value on a custom object then pushing that  to a hidden field on a contact using APEX.

 

I am trying to count the number of active__c Resume_subscriptions__c on a contact. this is not a master relationship so im having issues counting the ones that are active__c only and populating the Active_Resumes__c field on the contact with the active__c count.

 

There are many code samples out there but i have no idea where to start. YOur help is Very Much Appriciated!!

 

Cheers,

Niki

Hello - I am having issues with my dependent picklists not working on my VS Page. Everything is working correctly but my Dependent picklist fields arent?

 

This was working in my sandbox but now in Prod im having issues. I moved everything through a changeset so it all should match.

 

PLEASE Help!

 

Here is my page:

<apex:page standardController="Candidate__c" extensions="PublicJobApplicationExtension" title="Job Application" showheader="false" >

<style>
<!--Link Style-->
a:link {color:#1891ce text-decoration: Underline;}     <!-- unvisited link -->
a:visited {color:#1891ce ; text-decoration: Underline;} <!-- Visited link -->
a:hover {color:#1891ce ; text-decoration: Underline;}  <!-- Mouse Over link -->
a:active { color:#1891ce ; text-decoration: Underline; } <!-- selected link -->

Table.jsistyle{
border-style:solid;
border-width:2px;
border-color:#74BDE2;
text-align:left;
background-color:white;
padding:15px;
width:350px;
height:45px;
font-family:Verdana,Geneva,sans-serif;
font-size:15px;
}

th.text{
text-align:right;
margin-left:15px;
}

th.class{
colspan:2;
background-color:#ffffff;
width:100%;
font-size:15px;
color:#003698;
font-family:Verdana,Geneva,sans-serif;
}

th.classhead{
background-color:#ebeff3;
width:100%;
font-size:13px;
color:black;
font-family:Verdana,Geneva,sans-serif;
}

th.classhead2{
background-color:#ebeff3;
font-size:13px;
color:black;
font-family:Verdana,Geneva,sans-serif;
}

Table.jsistyle1{
border-style:solid;
border-width:2px;
border-color:#74BDE2;
text-align:left;
width:250px;
background-color:white;
padding:15px;
font-family:Verdana,Geneva,sans-serif;
}

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

table.margintop{
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.innertable{
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:#ebeff3;
}

table.innertable2{
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;
}


p.text{
text-align:left;
font-family:Verdana,Geneva,sans-serif;
font-size:15px
}

p.text3{
text-align:left;
font-family:Verdana,Geneva,sans-serif;
font-size:12px
}
p.textDT{
text-align:left;
font-family:Verdana,Geneva,sans-serif;
font-size:11px
}

h1.margin{
margin-top:0px;
margin-bottom:0px;
margin-right:50px;
margin-left:200px;
}



</style>
<!--Start Form-->
<apex:form >
<apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em;"/>
<apex:pageBlock mode="edit" >

<!-- Image Header -->
<head>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>
<br/>
<!---Horizontal Rule -->
<hr width="92%" color="#63a4c5" size="0.5" /> 
</head>
<br/>
<h1 class="margin" style="font-family:Verdana,Geneva,sans-serif;font-size:20px;font-color:#1891ce" >Registration</h1>

<!-- Start Body -->
<body bgcolor="#ffffff">


<br></br>

<!--Outside Table 1-->
<table class="margin" cellspacing="2"  >


<!--Start Content Table-->
<td>
<tr>
<td colspan="2" >
<table class="margintop">
<th class="class"> Career Fair Registration Information:</th>


<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable">
<tr>
<td>
<p class="text3"><b>When:</b> April 10, 2012 <br/> <b>Where:</b> <a target="blank" href="http://www.marriott.com/hotels/travel/nycea-new-york-marriott-east-side/">Marriott East Side</a> <br/> 525 Lexington Avenue at 49th Street, New York, NY 10017</p><br/>
</td>
</tr>


<td><!-- Why Attend inner table-->

<tr>
<td colspan="2" width="100%">

<th class="classhead" colspan="3" >Why Attend?</th>
<table class="innertable2">
<tr>
<td>
<p class="textDT"><b><u>Why Attend?</u></b></p>
<p class="textDT">Don’t miss this exciting opportunity to network with fellow Physicians, Nurse Practitioners and Physician Assistants in the New York City region! This is a rare opportunity to speak face-to-face with representatives from top healthcare employers actively seeking 
out talented candidates in multiple specialties. And, be certain to attend the keynote speaker session clarifying upcoming changes to ICD-10-CM and HIPAA 5010, presented by Nancy Maguire, nationally-renowned procedural and diagnostic coding instructor.</p>

</td>
</tr>
</table>
</td>
</tr>
</td><!--End Why Attend inner table-->

<th class="classhead" colspan="3" >Details:</th><!--Details table-->
<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable2">
<tr>
<td>
<p class="textDT"><b><u>Nurse Practitioner and Physician Assistant Attendees: 3:00 pm-7:00 pm</u></b></p>
<ul>
<li><p class="textDT">Career Fair (3:00 pm-5:00 pm): Connect with employers to learn about the available opportunities within the organization. Complimentary snacks will be served during this time to network with other colleagues in attendance.</p></li>
<li><p class="textDT">Keynote Speaker (5:00 pm-7:00pm): Nancy Maguire addresses the ICD-10-CM and HIPAA 5010 initiative and how to prepare for a successful transition.</p></li>
</ul>

<p class="textDT"><b><u>Physician Attendees: 5:00 pm-9:00 pm</u></b></p>
<ul>
<li><p class="textDT">Keynote Speaker (5:00 pm-7:00 pm): Nancy Maguire addresses the ICD-10-CM and HIPAA 5010 initiative and how to prepare for a successful transition..</p></li>
<li><p class="textDT">Career Fair (7:00-9:00): Connect with employers to learn about the available opportunities within the organization. Complimentary hors d'oeuvres and cocktails will be served during this time to network with other colleagues in attendance.</p></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->



</table>
</td>
</tr>
</td><!--inner table-->
</table>
</td>
</tr>
</td><!--End Content Table-->


<!-- Form Fields-->
<!--Table2-->
<td colspan="2" >
<table class="margintop" >
<tr >
<td colspan="2" align="center"><apex:commandButton value="Register Now" action="{!saveApplication}"/><apex:commandButton value="Cancel" onclick="top.history.go(-1);return false;"/></td>
</tr>

<th class="class" colspan="2" >Create Your Profile:</th>

<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable">
<th class="classhead" colspan="3" >General Information:</th>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr >
<td>First Name:<apex:inputField required="true" style="width:90%"  value="{!Candidate__c.First_Name__c}"/></td>
<td>Last Name: <apex:inputField required="true" style="width:95%"  value="{!Candidate__c.Last_Name__c}"/></td>
</tr>
<tr>
<td>Email Address:<apex:inputField required="true" style="width:90%" value="{!Candidate__c.Email_Address__c}"/></td>
<td>Confirm Email:<apex:inputField required="true" style="width:95%" value="{!Candidate__c.Confirm_Email__c}"/></td>
</tr>

<tr>
<td>Password:<apex:inputSecret required="true" style="width:90%" value="{!Candidate__c.Password__c}"/></td>
<td>Confirm Password:<apex:inputSecret required="true"  style="width:95%" value="{!Candidate__c.Password_Confirmation__c}"/></td>
</tr>

<tr>
<td>Country: <apex:inputField required="true" style="width:90%" value="{!Candidate__c.Country__c}"/></td>
<td>Zip Code:<apex:inputField required="true" style="width:95%" value="{!Candidate__c.Zip_Code__c}"/></td>
</tr>
<tr>

</tr>


</table>
</td>
</tr>
</td><!--inner table-->
</table>
</td><!--End First table-->

<!--Second Resume Table-->
<td>
<tr>
<td colspan="2" >
<table class="margintop">
<th class="class"> Post your Resume:</th>

<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable">
<th class="classhead" colspan="3" >Resume Information:</th>
<tr>
<td>
<p class="text3">By registering online for the Healthcare Career Fair, you will be posting your resume in the <i>HEALTH</i>e<b>CAREERS</b> resume database. You may choose to post your resume confidentially. When you “post” your resume, you add it to the database that employers search to find matches for their jobs, increasing your exposure to employers. Many employers don’t list all of their jobs, so posting your resume ensures you don’t miss a great opportunity.</p>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr>
<td><apex:inputFile required="true"  accept="doc, txt, pdf" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" value="{!resume}"/></td>
</tr>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<td>
<p>Be sure to remove your name and contact info from the actual resume document. You'll receive emails from <i>HEALTH</i>e<b>CAREERS</b> Network with information about employers that are interested in you, and you choose whether or not to contact them. </p>
</td>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr>
<td><apex:inputField value="{!Candidate__c.Confidential__c}"/>&nbsp;List my name as confidential.</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->
</table>
</td>
</tr>
</td><!--End Resume Table-->

<!--Third Table--><!--Dicipline Tables-->
<td>
<tr>
<td colspan="2" width="100%">
<table class="margintop">
<th class="class" colspan="3" >Select Your Position Preference:</th>
<tr>
<td>
<td>
<tr>
<td colspan="2" width="100%">
<table class="innertable"><!--inner table-->
<th class="classhead" colspan="3" >Preferred Job Categories:</th>
<tr>
<td>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr >
<td><apex:inputField required="true"  value="{!Candidate__c.JobSeeker_Type__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Discipline_Name_Level_2__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Sub_Discpline_Level_3__c}"/></td>
</tr>
<tr>
<td><apex:inputField value="{!Candidate__c.JobSeeker_Type_2__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Discipline_Name_Level_2_2__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Sub_Discpline_Level_3_2__c}"/></td>
</tr>
<tr>
<td><apex:inputField value="{!Candidate__c.JobSeeker_Type_3__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Discipline_Name_Level_2_3__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Sub_Discpline_Level_3_3__c}"/></td>
</tr>
</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->

<!--work locations-->
<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable">
<th class="classhead" colspan="3" >Preferred Work Locations:</th>
<tr>
<td>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr >
<td><apex:inputField required="true" id="Preferred_Work_Locations_Country__c" value="{!Candidate__c.Preferred_Work_Locations_Country__c}"/></td>
<td><apex:inputField id="Preferred_Work_Locations_state__c"   value="{!Candidate__c.Preferred_Work_Locations_state__c}"/></td>
<td><apex:inputField id="Preferred_Work_Locations__c"         value="{!Candidate__c.Preferred_Work_Locations__c}"/></td>
</tr>
<tr>
<td><apex:inputField value="{!Candidate__c.Preferred_Work_Locations_Country_2__c}"/></td>
<td><apex:inputField Value="{!Candidate__c.Preferred_Work_Locations_State_2__c}"/></td>
<td><apex:inputField value="{!Candidate__c.Preferred_Work_Locations_2__c}"/></td>
</tr>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr>
<td colspan="2" >Willing to Relocate<apex:inputField required="true" value="{!Candidate__c.Willing_to_Relocate__c}"/></td>
</tr>
</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->

</td>
</tr>
</table>
</td>
</tr>
</td>

<!--Fourth Table--><!--Demographic Tables-->
<td>
<tr>
<td colspan="2" width="100%">
<table class="margintop">
<th class="class" colspan="3" >Select Your Employment Preferences and Demographic Information:</th>
<tr>
<td>

<td>
<tr>
<td colspan="2" width="100%">
<table class="innertable"><!--inner table-->
<th class="classhead" colspan="3" >Education and Experience:</th>
<tr>
<td>&nbsp;&nbsp; </td>
</tr>
<tr>
<td>Years of Experience:<apex:inputField required="true"   value="{!Candidate__c.Years_of_exp__c}"/></td>
<td>Education Level:<apex:inputField required="true"   value="{!Candidate__c.Education_Level__c}"/></td>
<td>Additional Languages:<apex:inputField required="true"   value="{!Candidate__c.Additional_Languages__c}"/></td>
</tr>
<tr>
<td>
<tr >
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Other:&nbsp;<apex:inputField value="{!Candidate__c.Education_Level_Other__c}"/></td>
<td>Other:&nbsp;<apex:inputField value="{!Candidate__c.Additional_Languages_Other__c}"/></td>
</tr>
</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->

<!--Medical Licenses-->
<td><!--inner table-->
<tr>
<td  colspan="3" width="100%">
<table class="innertable">
<th class="classhead2" >Medical Licensures:</th>
<th class="classhead2" >Employment Preferences:</th>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>I am licensed to practice medicine in the <br/>following states/territories:
<td >Work Authorization:<apex:inputField required="true" value="{!Candidate__c.Work_Authorization__c}"/> <br/></td>
<tr>
<td><apex:inputField required="true" value="{!Candidate__c.Medical_State_Licensures__c}"/></td>
<td>Preferred Employment Type:<apex:inputField required="true" value="{!Candidate__c.Preferred_Employment_Type__c}"/></td>
</tr>

</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->



<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable">
<th class="classhead" colspan="3" >Demographic Information:</th>

<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">(You will not be subject to adverse action or treatment if you choose 'Decline to Identify' as an answer.)
<tr>
<td>Gender:&nbsp;<apex:inputField value="{!Candidate__c.Gender__c}"/></td>
<td>Ethnicity:&nbsp;<apex:inputField value="{!Candidate__c.Ethnicities__c}"/></td>
</tr>

</td>
</tr>
</table>
</td>
</tr>
</td><!--inner table-->

</td>
</tr>
</table>
</td>
</tr>
</td>

<!-- Last Table-->
<!--Table2-->
<td colspan="2" >
<table class="margintop" >


<td><!--inner table-->
<tr>
<td colspan="2" width="100%">
<table class="innertable">

<tr >
<td colspan="2" align="center"><apex:commandButton value="Register Now" action="{!saveApplication}"/><apex:commandButton value="Cancel" onclick="top.history.go(-1);return false;"/></td>
</tr>

</table>
</td>
</tr>
</td><!--inner table-->
</table>
</td><!--End Last table-->

<!--Outside Table 1 End--></table>

<!--closing tags-->
</body>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Cheers, Niki

Good Morning-

 

I am trying to create a trigger that will count the number if active line items on a contact. Logic is I need to see how many resume subscriptions are active on one contact. Then add a value to my look up field that does not allow the user to select a contact that already has an active sub.

 

I am traveling all week and need some help creating the trigger.

 

Any help would be greatly appreciated.

 

Cheers,

Niki

Hello - I am trying to update the Unitprice on the opportuntiylineitem when a discount is added/removed on the opportuntiy. I have code here but it is not working. Any help would be greatly appriciated!!!

 

The Opportuntiy discount field is called "Ad_Agency_Discount__c". 

 

 

trigger AgencyDiscount on Opportunity (after update) {

List<Opportunity> discopps=new List<Opportunity>();

for (Opportunity opp : trigger.new)
   {
       Opportunity discOpp=trigger.oldMap.get(opp.id);
       if  (opp.Ad_Agency_Discount__c >0.00)

       {
          discopps.add(opp);
       }
   }
   if (!discopps.isEmpty())

{
List<OpportunityLineItem> olis = [SELECT ID,UnitPrice ,OpportunityLineItem.opportunity.Ad_Agency_Discount__c,Opp_Agency_Discount__c FROM OpportunityLineItem WHERE OpportunityId in :discopps];



List<Opportunity> opps=new List<Opportunity>();
for (OpportunityLineItem OLupdisc: olis)
{

For (integer i = 0; i < OLupdisc.opportunity.Ad_Agency_Discount__c; i++){

OpportunityLineItem newUnitPrice = new OpportunityLineItem ();
newUnitPrice.unitprice = OLupdisc.unitprice-(OLupdisc.unitprice *OLupdisc.opportunity.Ad_Agency_Discount__c);

 update OLupdisc;

}

}

}
}

 

 

Thank you, 

Niki

Hello - I am trying to calculate the number of business hours it took for one of my data analsys to triage a new Regestration (account), i need to have business hours between 7:00 am to 6:00pm and excluding weekends. 

 

Any help would be AWESOME!

 

Cheers,

Niki

Hello,

I need to create a report with the following catagory, it may look simple but can't generate in professional edition 

All contacts without opportunity.

i have tried rollup summay field on account, it shows all contacts(with/without opportunity) related to account 

I cannot create a formula or rollup field in contact to calculate total opportunities since there is no any direct relationship between contact and opportunities.


I can create report type - opportunities with contact role but there is no cross filter functionality available on professional edition also if i use the filter contact id equal none its not at all filtering properly. This kind of relationship filter is not implemented i guess.

If anyone came across same situation and found any solution for this PLEASE help me.

Email - sthandavarayan@gtr.net

Hello - I have a custom object called a Sectacular__c that is located on the OpportutiyLineItem.

 

I need to roll up the count of all the Products (opportutniyLineItems) the Spectatular has.

 

I have gotten the following error but can not figure out the issue:

Error	Error: Compile Error: Didn't understand relationship 'OpportunityLineItem' in FROM part of query call. 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. at line 10 column 30

 

 

Here is my code:

trigger OppLineItmRollup on Spectacular__c (after insert,after update)
{
   
  Set<id> RollChilSet  = new Set<id>();
  List<Spectacular__c> updateList = New List<Spectacular__c>();
  for(OpportunityLineItem rollUpchild :trigger.new){
      RollChilSet.add(rollUpchild.Spectacular__c); 
  }

   for(Spectacular__c rolPar:[select id,Sponsorships_Sold__c,Sold_Amount__c,(select id, UnitPrice, Quantity, Spectacular__c FROM OpportunityLineItem) FROM Spectacular__c where id IN:RollChilSet]) {
  decimal totalval = 0;  
 
    for(OpportunityLinrItem rol : rolPAr.OpportuntityLineItem){
    totalval = totalval  + rol.Quantity;
   
     }  

    rolPa.Sponsorships_Sold__c = totalval ;
    updateList.add(rolPar);

    }

   update updateList;

 }

 Please help.

Niki

Hello - I have a trigger that inserts a task in my opportunity when the opp is cloosed won. Now i need to eclude users with a role = inside sales. i have it in there but it is not working?

 

Also - i need help bringing my code up to 100%

 

any help would be awesome. Thank you

 

public class TasksForOpportunitiesClosedToContracts 
{
    public static void createTasksForOpportunityClosedToContract(Opportunity[] opportunities)
    {
        RecordType RecType = new RecordType();  
        RecType = [SELECT ID FROM RecordType WHERE Name = 'SAM Task'];
        

        for (Integer i = 0; i < opportunities.size(); i++) 
        {
            IF (opportunities[i].StageName == 'Closed Won' &&
                opportunities[i].LeadSource != 'Purchased from Site' &&
                opportunities[i].Message_Sent__c == false &&
                opportunities[i].Owner.UserRole.Name !='Inside Sales Representative'&&
                opportunities[i].Count_of_Pending_RS__c==0) 
            {
                Account acct = new Account();
                Task newContractTask = new Task();                
                
                acct = [SELECT client_id__c FROM Account WHERE ID = :opportunities[i].AccountId];
                                
                newContractTask.client_id__c = acct.client_id__c;
                newContractTask.OwnerID = opportunities[i].Account_Manager__c;
                newContractTask.Subject = 'New Closed Won Opportunity';
                newContractTask.Description = opportunities[i].Description;
                newContractTask.WhatID = opportunities[i].ID;
                newContractTask.Status = 'Not Started';
                newContractTask.RecordTypeID = RecType.ID;
                newContractTask.Priority = 'High';
                newContractTask.Type = 'New Closed Won Opportunity';
                newContractTask.ActivityDate = system.today();
                newContractTask.reminderdatetime = system.now();
                newContractTask.isreminderset = false;
                newContractTask.Short_Description__c = 'Create Contract/ Activate Job';
    
                insert newContractTask;

                
            } 
            
        } 
      } 
    
    static testMethod void test_trTasksForOpportunitiesToContracts()
    {
        Opportunity candidateOpportunity = [Select opp.StageName, opp.LeadSource From Opportunity opp 
                                            where opp.StageName != 'Closed Won' 
                                            and opp.StageName != 'Closed Lost' 
                                            and opp.Billing_is_different_than_Account__c = false 
                                            LIMIT 1];
        candidateOpportunity.StageName = 'Closed Won';
        candidateOpportunity.Billing_Email__c = 'test@healthecareers.com';
        candidateOpportunity.Billing_Contact__c = 'Test Contact' ;
        candidateOpportunity.Invoice_Delivery_Method__c = 'Email';
        candidateOpportunity.Payment_Method__c = 'Invoice';
        candidateOpportunity.Billing_Contact__c = 'Test Contact' ;
        candidateOpportunity.Type = 'Renewal';
        candidateOpportunity.New_Dollar_Amount__c =0;
        candidateOpportunity.Win_Loss_Notes__c = 'These are test notes.';
        update candidateOpportunity;
        
        Task newContractTask = [select Type from Task where WhatId = :candidateOpportunity.Id and Subject = 'New Closed Won Opportunity' LIMIT 1];
        System.assertEquals('New Closed Won Opportunity', newContractTask.Type);
        
    }
    
    
}

 

I have a page redirect/Save controller and need help wrighting a test class for it.  I have 19% covered right now and need 100%

 

Any help would be appriciated

Niki

 

Controller and Test:

public class mywebLeadController {
    Lead lead;

    public Lead getLead() {
        if(lead == null) lead = new Lead();
        return lead;
    }

    public PageReference savelead() {
        // Add the lead to the database. 
        insert lead;
        
        // Send the user to the landing page for the new lead.
        PageReference leadPage = page.WebLeadLandingPage;
        leadPage.setRedirect(true);
        return leadPage;
    }
    
   
   
    @IsTest static void testSave() { 
            
    Lead lead = new Lead ();
    mywebLeadController pjae = new mywebLeadController (); 
            
    Lead.FirstName = 'Test';
    Lead.LastName = 'Test';
    Lead.Company = 'OTJ - NG';
    Lead.Email = 'test@otj.com';
    
    insert lead;
    
    PageReference leadPage = page.WebLeadLandingPage;
    leadPage.setRedirect(true);
    
    System.debug('the current page is...' +ApexPages.currentPage() );
       
    
    }
}//End

 

Hello - I need help with building a GIUD (UUID) in SFDC? we are revamping our integration with our IT department and they want me to build a GUID in SFDC. I have never done this and have no idea where to start. I have found some sample code and this dosent work?

 

global class guidGenerator {

    private static String kHexChars = ’0123456789abcdefABCDEF’;

    global static String generateGUID(){

        String returnValue = ”;
        Integer nextByte = 0;
        for(Integer i = 0; i &lt; 16; i++){
            if(i==4 || i==6 || i==8 || i==10){
                returnValue += ‘-’;
            }
            
            nextByte = (Math.round(Math.random() * 255)-128) &amp; 255;

            if(i==6){
                nextByte = nextByte &amp; 15;
                nextByte = nextByte | (4 &lt;&gt; 4);
            returnValue += charAt(kHexChars,nextByte &amp; 15);
        }
        return returnValue;
    }

    public static String charAt(String str, Integer index){
        if(str == null){
            return null;
        }
        if(str.length() &lt;= 0){
            return str;    
        }
        if(index = str.length()){
            return null;    
        }
        return str.substring(index, index+1);
    }
}

 

ANY help would be much appriciated.

 

Thank you!

NIki

  • September 14, 2012
  • Like
  • 0

Can anyone help me move my coverage for this trigger to a higher %? any help is appriciated.

 

Lines not Covered

:

trigger trg_new_AdProductFulfillment on Opportunity (after update)
{
   List<Opportunity> closedWonOpps=new List<Opportunity>();

   for (Opportunity opp : trigger.new)
   {
       Opportunity oldOpp=trigger.oldMap.get(opp.id);
       if ( (opp.StageName=='Closed Won') &&
            (oldOpp.StageName!='Closed Won')&&
            (opp.Message_Sent__c== False))
       {
          closedWonOpps.add(opp);
       }
   }
    
   if (!closedWonOpps.isEmpty())
   {
    List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportuntiy_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True' and
        OpportunityId in :closedWonOpps];

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   for (OpportunityLineItem oli : olis)
   {
    
    For (integer i = 0; i < oli.Quantity; i++){
            Ad_Product_Fulfillment__c newaf= new Ad_Product_Fulfillment__c();
            newaf.Opportunity__c = oli.Opportunityid;
            newaf.Placement__c = oli.Standard_RateproductID__c;
            newaf.Account__c = oli.Account_ID__c;
            newaf.IO_Start_Date__c = oli.Closed_Won_Date__c;
            newaf.PO_IO_Number__c = oli.PO_IO_Number__c;
            newaf.Quantity__c = oli.Quantity;
            newaf.Expiration_Date__c = oli.Closed_Won_Date__c +365;
            newaf.Account_Executive__c = oli.Opportuntiy_Owner_id__c;
            newaf.Account_Manager__c = oli.Account_Manager_ID__c;
            afToInsert.add(newaf);
       }
          }

    insert afToInsert;
   }
}

 

 

Here is my Test Class:

@isTest(SeeAllData=True)

Public class Testtrg_new_AdProductFulfillment{

static testmethod void Testtrg_new_AdProductFulfillment()

{


List<Opportunity> closedWonOpps=new List<Opportunity>();

Opportunity opp = new Opportunity();
opp.StageName='Closed Won';
opp.Message_Sent__c= False;
opp.Name = 'Test';
opp.Account_Manager__c = '00550000000saAA';
opp.CloseDate =Date.newInstance(2012, 01, 15);
opp.Product_Interest__c = 'Job Posting';
opp.Billing_Email__c = 'test@otj.com';
opp.New_Dollar_Amount__c=100;
insert opp;

       {
          closedWonOpps.add(opp);
       }

List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportuntiy_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True'and
        OpportunityId in :closedWonOpps];
        
OpportunityLineItem oppt = new OpportunityLineItem();
oppt.OpportunityId=opp.Id;
oppt.Quantity =1;
oppt.Cost_Type__c ='weekly';
oppt.TotalPrice =100;
oppt.PricebookEntryId='01u50000003SHVz';
insert oppt;

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   {
Ad_Product_Fulfillment__c adg= new Ad_Product_Fulfillment__c();
            adg.Opportunity__c = '006W0000002VxWF';
            adg.Placement__c = '01t50000001YRdD';
            adg.Account__c = '001W0000004yqYJ';
            adg.IO_Start_Date__c = Date.newInstance(2012, 01, 15);
            adg.PO_IO_Number__c = '123';
            adg.Quantity__c = 1;
            adg.Expiration_Date__c = Date.newInstance(2012, 01, 15);
            adg.Account_Executive__c = '00550000000saAA';
            adg.Account_Manager__c = '00550000000saAA';
insert afToInsert;
}

}}

 Please help!

 

Thank you

Niki

Can anyone help with the test coverage on this trigger? I am terrable with test classes.

 

trigger trg_new_AdProductFulfillment on Opportunity (after update)
{
   List<Opportunity> closedWonOpps=new List<Opportunity>();

   for (Opportunity opp : trigger.new)
   {
       Opportunity oldOpp=trigger.oldMap.get(opp.id);
       if ( (opp.StageName=='Closed Won') &&
            (oldOpp.StageName!='Closed Won')&&
            (opp.Message_Sent__c== False)) 
       {
          closedWonOpps.add(opp);
       }
   }
    
   if (!closedWonOpps.isEmpty())
   {
    List<OpportunityLineItem> olis = [SELECT ID, OpportunityId,Account_Manager_ID__c,Opportunity_Owner_id__c,PO_IO_Number__c, Account_ID__c,Standard_RateproductID__c,Closed_Won_Date__c,
        Quantity FROM OpportunityLineItem WHERE Ad_Product_Fulfillment__c ='True' and
        OpportunityId in :closedWonOpps];

    List<Ad_Product_Fulfillment__c> afToInsert=new List<Ad_Product_Fulfillment__c>();
   for (OpportunityLineItem oli : olis)
   {
    
    For (integer i = 0; i < oli.Quantity; i++){
            Ad_Product_Fulfillment__c newaf= new Ad_Product_Fulfillment__c();
            newaf.Opportunity__c = oli.Opportunityid;
            newaf.Placement__c = oli.Standard_RateproductID__c;
            newaf.Account__c = oli.Account_ID__c;
            newaf.IO_Start_Date__c = oli.Closed_Won_Date__c;
            newaf.PO_IO_Number__c = oli.PO_IO_Number__c;
            newaf.Quantity__c = oli.Quantity;
            newaf.Expiration_Date__c = oli.Closed_Won_Date__c +365;
            newaf.Account_Executive__c = oli.Opportunity_Owner_id__c;
            newaf.Account_Manager__c = oli.Account_Manager_ID__c;
            afToInsert.add(newaf);
       }
          }

    insert afToInsert;
   }
}

 Thank you,

Niki

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