• lescclarkcpd
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 35
    Questions
  • 40
    Replies
Hi

I have a whole bunch of contacts that have "Customer Portal User" accounts associated with them.  

I want to 'Mass disable' some of these contacts from the customer portal accounts.  You can do this manually on each contact by hitting 'manage external users' and then 'disable customer user' but want to see if I can create a trigger to do this en mass, any ideas as to the method to do this, can't sem to find reference to this anywhere

thanks
les

Hi

 

I am getting the hang of these but need to bulkify this trigger.  Essentially it takes a course_application and checks to see if the course applicant is a campaign member.  There are a couple of many to many relationships so suspect that I will need to use a map with a list?  If a campaign member exists it updates it, if not create a new one.  Managed to do this by iterating through the course apps and building a list then checking the size of the list.  However, It also doesn't take into account any new course_applications created during the fioring of the trigger.  Any help appreciated

 

les

 

 List<CampaignMember> cmbadd = new List<CampaignMember>();
       List<CampaignMember> cmbupdate = new List<CampaignMember>();
        
        for(Course_Application__c c:Trigger.new)      	
        {
        List<CampaignMember> cammem =[select id
             from CampaignMember
             where CampaignMember.contactid =:c.Course_Applicant_del__c 
             AND CampaignMember.CampaignId=:c.PullCampaignID__c];
    
             if(cammem.size() == 0)
             	{          
		     		CampaignMember cmb = new CampaignMember(contactId=c.Course_Applicant_del__c, CampaignId=c.PullCampaignID__c, status=c.status__c);
		            cmbadd.add(cmb);
		            
		     	}    
             	Else
             	{
             		 CampaignMember cmbup = cammem[0];
		             cmbup.status=c.status__c;
		             cmbupdate.add(cmbup);
		             
             	} 
             	
        } 
                
    	    Database.insert(cmbadd);
    	    Database.update(cmbupdate);

 

Hi

 

I am trying to use the following code for a bulkified trigger to roll up and update the number of course applications for each course.  I then want to update each course with the aggregate value into the 'numberOfCourseApps' field.  I'm pretty sure that I have the right syntax but get an error - incompatible key type eor Object for MAP.

 

Is this possible ? If not how can I then take the course ID and update the 'numberOfCourseApps' field

 Map<course__c, Integer> coursesToassigntsMap = new Map<course__c, Integer>();
	   set<Id> courseIds = new Set<Id>();
	   for(Course_Application__c a: trigger.new){
		   courseIds.add(a.Id);	   
   		}
	   for (AggregateResult agr :[select count(id) idcount,course_del__c from Course_Application__c where course_del__r.Id in :CourseIds and status__c='Ordered'group by course_del__c])
	   						     
		{
           coursesToassigntsMap.put(agr.get('course_del__c'), integer.valueof(agr.get('idCount')));
		}

 

Hi

 

I am pretty new to apex and have had a good few goes at trying to get my head around bulkyfying this trigger.  I know I need to use a map & an aggregateresult loop but just cant seem to get the syntax right.

 

any help appreciated

 

for(Course_Application__c c:Trigger.new)      
        {
        Course__c c = [select id, Confirmed_applications__c  from Course__c where Id =:c.id];
        Integer u = [select Count() from Course_Application__c where course_del__r.Id =:crsId and status__c='Ordered'];
        c.Confirmed_applications__c=u;
        update c;
}

 thanks

les

 

 

Hi

 

We are using session IDs to track items that a public guest user adds to a cart, am i right in saying that if there are 2 users, on 2 different machines, in the same location that they will have the same session ID.  It certainly seems that way.

 

thanks

les

Hi

 

we are running a site and have created some cart functionality, a 'public guest user' can add items to their cart, creates a custom object and updates the number of items in the cart.  this all works fine in our sandbox but once in production we are experienceing problems with response times when, having created a new cart item,  we query how many items are in the cart - it can be in minutes.  There are no issues with permissions, shares etc.  if you log in as a High Vol Cust Portal User the problem goes away.  I'm looking for some advice / tools to be able to monitor how well this performs & to identify what is wrong with the code - having had a look at pother posts i'm sure it may have something to do with referencing static resources ??

 

thanks in advance

 

les

Hi

 

Newbie here! I have the following but can't cover most of the code, any help really appreciated.

 

public class MyProfilePageController {

 

    private User user;

    public boolean error = false;

    private boolean isEdit = false;

    public User getUser() {

        return user;

    }

    public MyProfilePageController() {

        user = [SELECT id, email, firstname, salutation__c            

FROM User

                WHERE id = :UserInfo.getUserId()];

        if (user.usertype == 'GUEST') {

            throw new NoAccessException();

        }

    }

public Boolean getIsEdit() {

        return isEdit;

    }   

    public void poedit() {

        isEdit=true;

    }        

    public pagereference save() { 

    if(user.salutation__c=='None'){

        if(error!=TRUE){

            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'The following are required fields:');

            ApexPages.addMessage(msg);        

            }

            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Salutation');

            ApexPages.addMessage(msg);

             error=TRUE;

        }

       if(user.firstname==''

        {

            if(error!=TRUE){

            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'The following are required fields:');

            ApexPages.addMessage(msg);        

            }

            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'First Name');

            ApexPages.addMessage(msg);

            error=TRUE;

        }

       

        }

        if(error==TRUE){

        error=false;

        return null;

        }

                return null;

   }     

    public void cancel() {

        isEdit=false;

        user = [SELECT id, email, username, companyName, salutation__c,billing_street__c,Billing_city__c,billing_county__c,billing_postcode__c,Billing_Address_same_as_Mailing__c,communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,

                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email, Practitioner_Speciality__c

                FROM User

                WHERE id = :UserInfo.getUserId()];

    } 

   

    static testMethod void testSave() {         

            account acc = new account(name='Portal Registration Account');

            insert acc;

            contact con = new contact (firstname='First',lastname='Test', accountid=acc.id);

            insert con;

        

        Profile p = [select id from profile where name='OAWU Feb 11'];

        User us = new user(alias = 'standt', email='standarduser@testorg.com', emailencodingkey='UTF-8', lastname='Testing'

            languagelocalekey='en_US',localesidkey='en_US', profileid = p.Id, timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com',contactid=con.id, firstname='firstname');

            insert us;

            

         System.runAs(us) {

            MyProfilePageController controller = new MyProfilePageController();

            System.assertEquals(us.Id, controller.getUser().Id, 'Did not successfully load the current user');

            System.assert(controller.isEdit == false, 'isEdit should default to false');

            controller.poedit();

            System.assert(controller.isEdit == true);

            

            controller.cancel();

            System.assert(controller.isEdit == false);

            

            controller.getUser().Fax = randFax;

            controller.save();

            System.assert(controller.Error == false);

            controller.getisedit();           

        }    

      }

}

 

thanks

Hi

 

i'm pretty new to dev & need a test script for tbelow, I have covered everything else but this!  

 

public id appId {get; set;}

public Cart_item__c doRemoveApp() {

        Cart_item__c doomedAccts = [

                select id, name 

                from Cart_item__c 

                where id = :AppID]; 

        try {   

     

                delete doomedAccts;

        } 

        catch (DmlException e) { 

                // Process exception here  

                }

        return Null;

        }

 

thanks

 

 

hi

 

I am writing a trigger that updates a customer portal user when the associated contact is updated.  I have the class but only want to run the trigger when the contact has an associated cust portal user - I can't seem to find reference to this at all. y Trigger would be something like

 

trigger UpdateUserfromContact on Contact (after update) {

 

        Contact c =  Trigger.new[0];

        

        //And only if the contact has a related Customer Portal User associated

        

            UpdatePortalUserfromContact.updateUser(c.Id);

      

}

 

thanks

It requires an input, and it will only return a list of matching records with 1 column, and no option if the records you searched for arent what the user is looking for. Is there some functionality with this that is missing? Documentation - pfft!

Hi

 

I have a site that has been developed using xhtml & css, when I create VF pages I lose a lot of the formatting.  I'm an HTML / CSS beginner but understand that I may need to specify the doctype in the VF page.  My standard html page reads:

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>

 

 

When I try to replicate this in SF ie:

 

 

<apex:page showHeader="false" contentType="application/xhtml+xml">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

 

I get:

 

Error

Error: A DOCTYPE is not allowed in content.

 

I have looked at other threads relating to this but there doesn't seem to be a definitive answer.  I have tried  using apex:outputText but get issues with speechmarks etc -

 

Can anyone help me out with the code ?

 

Can I use xhtml in a vf page ??

Hi,

I displayed all records of an custom object.

 

when i placed mouse pointer(Mouseover) on a particular record. It need to display that record details as a popup menu.

I wrote a code in visulaforce page to display that particular records.

Please help me out.

 

Raju.b

Hi

 

I have created a cart that is available to unauthenticated users via my site.  It uses session ID to identify cart items.  It works fine.  To 'checkout' users must authenticate, and login as an AWU, this works fine.  

 

However, once logged in SF issues a new session ID which means that I am unable to tie up the cart items from when they where previously un-authenticated.

 

Any suggestions as to how I can overcome this:

 

- I appreciate that I  could ask all public users to authenticate prior to checking out but this doesn't suit workflow but yes they need to authenticate for other reasons.

- can I pass the 'unauthenticated' session ID through the login process

- start again !! ie another suggested way to build a cart that may overcome this problem

 

thanks

 

 

Hi

 

I have a custom object "Applications" that is linked to contacts.  I want to create a button that I can use on standard SF list pages that adds the related contacts to a campaign (users choice).  Is there some code that I can use that uses the standard sf functionality or do I need to create a vf page & controller 

 

thanks