• WaveOC
  • NEWBIE
  • 75 Points
  • Member since 2012

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

apex code:-

 

public with sharing class Mailer
{
public class Acccon
{
Boolean B=true;
Contact C{get;set;}
Account A{get;set;}

public Acccon(Contact Cpas)
{
C=Cpas;
}
public Acccon(Account Apas)
{
A=Apas;
}
}

public List<Acccon> ACCC{set;get;}
public List<Acccon> getACCC()
{
for(Contact c: [select Id, firstName, Email, Phone from Contact limit 10])
{

ACCC.add(new Acccon(c));
}
for(Account a: [select Name from Account limit 10])
{

ACCC.add(new Acccon(a));
}
return ACCC;
}
}

 

VF page code:-

<apex:page controller="Mailer">
<apex:pageBlock >
<apex:dataTable value="{!ACCC}" var="a">
<apex:column value="{!a.A.name}"/>

</apex:dataTable>
</apex:pageBlock>
</apex:page>

 

I'm Trying to add contact using apex code and when i'm running test it is showing successful but Contacts are not adding

Please suggest me the solution soon.....

Here is my Apex Code

 

@isTest
Public class Enterprise{
static testMethod void AddContact()
{
   Account newAccount = new Account (name='XYZ Organization',
BillingCity ='TestCity',
BillingCountry ='TestCountry',
BillingStreet ='TestStreet',
BillingPostalCode ='t3stcd3'
);

insert newAccount;

Contact NewContact = new Contact (
FirstName = 'xyzFirst',
LastName = 'XyZLast',
Account = newAccount,
Email = 'xyzmail@mail.com'
);
}
}

Hi,

I wrote some code to email a list of specific chatter groups that do not have full license users in the groups.  It works like a charm.  Then I wanted to get fancy and have the same list show on the visualforce page but what I thought would be a simple addition has had me spinning my wheels for over an hour now.  Any ideas would be appreciated.  Below is the error that I am receiving along with the VF page and the controller.

 

The error started when I added the datatable tag additon to the VF page and the getUsersChatterGroups method to the controller.  When I comment this line out in the VF page I can save the page and controller.  <apex:outputtext value="{!ug.ChatterGroupName}"/>

 

Please help!

 

Error

Error: Unknown property 'CFCT_UsersNotInChatterGroups_Controller.HelperClass.ChatterGroupName'

 

<apex:page Controller="CFCT_UsersNotInChatterGroups_Controller" action="{!startProcess}">
    <apex:pagemessages escape="false"/>
    <apex:dataTable value="{!UsersChatterGroups}" var="ug" id="theTable" rowClasses="odd,even" styleClass="tableClass">
        <apex:facet name="option">table option</apex:facet>
        <apex:facet name="header">table header</apex:facet>
        <apex:facet name="footer">table footer</apex:facet>
        <apex:column >
            <apex:facet name="header">Chatter Group</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputtext value="{!ug.ChatterGroupName}"/>
        </apex:column>
    </apex:dataTable>
</apex:page>

 

public class CFCT_UsersNotInChatterGroups_Controller {

    private List<User> userList;
    private List<CollaborationGroupMember> chatterGroupList;
    private List<HelperClass> UsersMissingInChatterGroups = new List<HelperClass>();
   
    private Map<id, String> userMap = new Map<id, String>();
    private Map<id, String> ChatterGroupUserMap = new Map<id, String>();
    private String htmlBody = '<table border="1"><tr><th>Chatter Group</th><th>User Name</th></tr>';
    private String plainTextBody = ''; 
        
    public void startProcess() {
         // Get user Information
         userList = [ SELECT id, Name
                      FROM User
                      WHERE isActive = TRUE AND
                            User.Profile.UserLicense.Name = 'Salesforce' ]; 
                                            
        for ( User u : userList ) {
            userMap.put(u.id,u.Name);
        }

        // Build List of Full License Users that do not exist in each Chatter Group
        BuildList('Group1');
        BuildList('Group2');
        BuildList('Group3');
        BuildAndSendEmail();
      
        
        String msg = 'Please check your email inbox for the list of users that need to be added to Chatter Groups.';
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM, msg);  
        ApexPages.addMessage(myMsg);     
    }
    
    public List<HelperClass> getUsersChatterGroups() {
        return  UsersMissingInChatterGroups;
    }
    
    // Get Chatter Group List
    // Interate through the User List while building the UsersMissingChatterGroup list
    private void BuildList( String ChatterGroupName ) {           
        chatterGroupList = [ SELECT MemberId, collaborationGroup.Name 
                             FROM CollaborationGroupMember
                             WHERE collaborationGroup.Name = :ChatterGroupName                     
                             ORDER BY collaborationGroup.Name ];                             
        
        for ( CollaborationGroupMember cg : chatterGroupList ) {            
            ChatterGroupUserMap.put(cg.MemberId, cg.collaborationGroup.Name);
        }                
        
        for ( User u : userList) {
            if ( !chatterGroupUserMap.ContainsKey(u.Id) ) {                                                              
                HelperClass UserMissingInChatterGroup = new HelperClass();
                UserMissingInChatterGroup.UserName = u.Name;
                UserMissingInChatterGroup.ChatterGroupName = ChatterGroupName;
                UsersMissingInChatterGroups.add(UserMissingInChatterGroup);
            }            
        }         
    }  
    
    private void BuildAndSendEmail() {
        String priorCGN = '';
        for ( HelperClass hc : UsersMissingInChatterGroups ) {
            if ( priorCGN !='' && priorCGN !=hc.ChatterGroupName ) { 
                htmlBody += '<tr><td align="center">====================</td><td align="center">===========</td></tr>';
            }
            htmlBody += '<tr><td>' + hc.ChatterGroupName + '</td><td>' + hc.UserName + '</td></tr>';
            plainTextBody += hc.ChatterGroupName + '\t' + hc.UserName + '\n';
            priorCGN = hc.ChatterGroupName;
        } 
        htmlBody += '</table>';
        sendEmail();
    }      
    
    private void sendEmail() {
        User currentUser = new User();
        currentUser = QueryBase.getCurrentUser();
        List<String> toAddresses = new List<String> {currentUser.Email};
        String replyToAddress = currentUser.Email;        
        Utils.EmailUtil email = new Utils.EmailUtil(toAddresses);
        email.plainTextBody(plainTextBody);
        email.htmlBody(htmlBody);
        email.senderDisplayName(currentUser.Name);
        email.subject('Users Not In Chatter Groups');
        email.replyTo(replyToAddress);
        email.sendEmail();
    }    
    
           
    // Helper Class
    private class HelperClass {         
        public String UserName;
        public String ChatterGroupName;
    }
}

 

Hi,

 

I am doing gotowebinar integration with salesforce. I am getting access token,refresh token,client id, organization key of gotowebinar in to salesfoce visualforce page. I have stored the accesstoken of gotowebinar in to one variable through apex class. When i am trying to get the data from gotowebinar to salesforce, it will throughs the error as

 

{"int_err_code":"InvalidToken","msg":"Invalid token passed"}

 

I have use the code for getting attendees details through this method.

 

public void performance()
{
s1=apexpages.currentpage().getparameters().get('code');
system.debug(accesstoken+'aaa==');
Http h = new Http();
HttpRequest req = new HttpRequest();
final string username = 'username';
final string password = 'welcome1';
//Blob headerValue = Blob.valueOf(username + ':' + password);
//String authorizationHeader = 'BASIC' + EncodingUtil.base64Encode(headerValue);
//req.setHeader('Authorization',authorizationHeader+accesstoken);
//String authorizationHeader = 'OAuth' +accesstoken +EncodingUtil.base64Encode(headerValue);
//req.setHeader('Authorization',authorizationHeader);
//req.setHeader('Authorization', 'OAuth ' +accesstoken);
//req.setHeader('Host','https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/attendees');
//req.setHeader('Authorization', 'OAuth '+accesstoken);
req.setHeader('Authorization:', 'OAuth oauth_token='+accesstoken);
//req.setHeader('Authorization: OAuth oauth_token=', accessToken);

req.setHeader('Connection','keep-alive');
req.setHeader('Content-Type', 'application/json;charset=UTF-8');
req.setMethod('GET');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/sessions/accesstoken/attendees/{registrantKey}');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/performance');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/sessions/'+accesstoken+'/performance');
req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/attendees');
system.debug(accesstoken+'aaa1==');
system.debug(req+'hh==');
HttpResponse res = h.send(req);
system.debug(accesstoken+'aaa2==');
res2=res.getbody();
system.debug('********'+res.getbody());
system.debug('111=='+res.getstatus());

}

 

Please help me, how to solve this issue.. Thanks in advance..

 

Thanks,

Lakshmi

apex code:-

 

public with sharing class Mailer
{
public class Acccon
{
Boolean B=true;
Contact C{get;set;}
Account A{get;set;}

public Acccon(Contact Cpas)
{
C=Cpas;
}
public Acccon(Account Apas)
{
A=Apas;
}
}

public List<Acccon> ACCC{set;get;}
public List<Acccon> getACCC()
{
for(Contact c: [select Id, firstName, Email, Phone from Contact limit 10])
{

ACCC.add(new Acccon(c));
}
for(Account a: [select Name from Account limit 10])
{

ACCC.add(new Acccon(a));
}
return ACCC;
}
}

 

VF page code:-

<apex:page controller="Mailer">
<apex:pageBlock >
<apex:dataTable value="{!ACCC}" var="a">
<apex:column value="{!a.A.name}"/>

</apex:dataTable>
</apex:pageBlock>
</apex:page>

Hi,

 

How do i start with this...

 

I want to copy data from one custom object and insert into other custom object using apex or any other feature.

 

Thanks,

Gaurav

 

I'm Trying to add contact using apex code and when i'm running test it is showing successful but Contacts are not adding

Please suggest me the solution soon.....

Here is my Apex Code

 

@isTest
Public class Enterprise{
static testMethod void AddContact()
{
   Account newAccount = new Account (name='XYZ Organization',
BillingCity ='TestCity',
BillingCountry ='TestCountry',
BillingStreet ='TestStreet',
BillingPostalCode ='t3stcd3'
);

insert newAccount;

Contact NewContact = new Contact (
FirstName = 'xyzFirst',
LastName = 'XyZLast',
Account = newAccount,
Email = 'xyzmail@mail.com'
);
}
}

Hi,

 

How display custom related list gor opportunity records in visual force page like same as standard related list and also

pagination for records, clicking on edit/del links it will open a pop up and modify records or delete records

when clicking on new it will open new pop up

 

 

 

Thank you

 

 

Hi,

I wrote some code to email a list of specific chatter groups that do not have full license users in the groups.  It works like a charm.  Then I wanted to get fancy and have the same list show on the visualforce page but what I thought would be a simple addition has had me spinning my wheels for over an hour now.  Any ideas would be appreciated.  Below is the error that I am receiving along with the VF page and the controller.

 

The error started when I added the datatable tag additon to the VF page and the getUsersChatterGroups method to the controller.  When I comment this line out in the VF page I can save the page and controller.  <apex:outputtext value="{!ug.ChatterGroupName}"/>

 

Please help!

 

Error

Error: Unknown property 'CFCT_UsersNotInChatterGroups_Controller.HelperClass.ChatterGroupName'

 

<apex:page Controller="CFCT_UsersNotInChatterGroups_Controller" action="{!startProcess}">
    <apex:pagemessages escape="false"/>
    <apex:dataTable value="{!UsersChatterGroups}" var="ug" id="theTable" rowClasses="odd,even" styleClass="tableClass">
        <apex:facet name="option">table option</apex:facet>
        <apex:facet name="header">table header</apex:facet>
        <apex:facet name="footer">table footer</apex:facet>
        <apex:column >
            <apex:facet name="header">Chatter Group</apex:facet>
            <apex:facet name="footer">column footer</apex:facet>
            <apex:outputtext value="{!ug.ChatterGroupName}"/>
        </apex:column>
    </apex:dataTable>
</apex:page>

 

public class CFCT_UsersNotInChatterGroups_Controller {

    private List<User> userList;
    private List<CollaborationGroupMember> chatterGroupList;
    private List<HelperClass> UsersMissingInChatterGroups = new List<HelperClass>();
   
    private Map<id, String> userMap = new Map<id, String>();
    private Map<id, String> ChatterGroupUserMap = new Map<id, String>();
    private String htmlBody = '<table border="1"><tr><th>Chatter Group</th><th>User Name</th></tr>';
    private String plainTextBody = ''; 
        
    public void startProcess() {
         // Get user Information
         userList = [ SELECT id, Name
                      FROM User
                      WHERE isActive = TRUE AND
                            User.Profile.UserLicense.Name = 'Salesforce' ]; 
                                            
        for ( User u : userList ) {
            userMap.put(u.id,u.Name);
        }

        // Build List of Full License Users that do not exist in each Chatter Group
        BuildList('Group1');
        BuildList('Group2');
        BuildList('Group3');
        BuildAndSendEmail();
      
        
        String msg = 'Please check your email inbox for the list of users that need to be added to Chatter Groups.';
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM, msg);  
        ApexPages.addMessage(myMsg);     
    }
    
    public List<HelperClass> getUsersChatterGroups() {
        return  UsersMissingInChatterGroups;
    }
    
    // Get Chatter Group List
    // Interate through the User List while building the UsersMissingChatterGroup list
    private void BuildList( String ChatterGroupName ) {           
        chatterGroupList = [ SELECT MemberId, collaborationGroup.Name 
                             FROM CollaborationGroupMember
                             WHERE collaborationGroup.Name = :ChatterGroupName                     
                             ORDER BY collaborationGroup.Name ];                             
        
        for ( CollaborationGroupMember cg : chatterGroupList ) {            
            ChatterGroupUserMap.put(cg.MemberId, cg.collaborationGroup.Name);
        }                
        
        for ( User u : userList) {
            if ( !chatterGroupUserMap.ContainsKey(u.Id) ) {                                                              
                HelperClass UserMissingInChatterGroup = new HelperClass();
                UserMissingInChatterGroup.UserName = u.Name;
                UserMissingInChatterGroup.ChatterGroupName = ChatterGroupName;
                UsersMissingInChatterGroups.add(UserMissingInChatterGroup);
            }            
        }         
    }  
    
    private void BuildAndSendEmail() {
        String priorCGN = '';
        for ( HelperClass hc : UsersMissingInChatterGroups ) {
            if ( priorCGN !='' && priorCGN !=hc.ChatterGroupName ) { 
                htmlBody += '<tr><td align="center">====================</td><td align="center">===========</td></tr>';
            }
            htmlBody += '<tr><td>' + hc.ChatterGroupName + '</td><td>' + hc.UserName + '</td></tr>';
            plainTextBody += hc.ChatterGroupName + '\t' + hc.UserName + '\n';
            priorCGN = hc.ChatterGroupName;
        } 
        htmlBody += '</table>';
        sendEmail();
    }      
    
    private void sendEmail() {
        User currentUser = new User();
        currentUser = QueryBase.getCurrentUser();
        List<String> toAddresses = new List<String> {currentUser.Email};
        String replyToAddress = currentUser.Email;        
        Utils.EmailUtil email = new Utils.EmailUtil(toAddresses);
        email.plainTextBody(plainTextBody);
        email.htmlBody(htmlBody);
        email.senderDisplayName(currentUser.Name);
        email.subject('Users Not In Chatter Groups');
        email.replyTo(replyToAddress);
        email.sendEmail();
    }    
    
           
    // Helper Class
    private class HelperClass {         
        public String UserName;
        public String ChatterGroupName;
    }
}

 

Is there any way to accept ownership through Link in Email. I want to make  some apex code logic where I click button 'Send owership Email'. It will send out email to number of persons. When first user click on that link he will get the ownership and if second user click that link he will get message that owner is already assgined.

 

Leave out any ideas you have.

 

Thanks  

 

Hi,

 

I need help in updating a parent record field with Yes or No value.

 

When I create a child record with lookup field value as hardcoded value, trigger get save but doesnt allow to save child record.

This is the code i am not able to save the child record. On child record I have visualforce page.

 

trigger ENT_Trigger_PopulateDistressedAA on ENT_NMTC_Distressed_Area_Association__c (after insert, after update)
{
    set<id> DealIDs = new set<id>();
    set<id> DdataIDs = new set<id>();
    
    for(ENT_NMTC_Distressed_Area_Association__c l : trigger.new)
    {
        DealIDs.add(l.NMTC_Deal__c);
    }
   
    List<ENT_NMTC_Deal__c> deals= [select id, PovRate2530__c from ENT_NMTC_Deal__c where id in :DealIDs ];
    
      deals[0].PovRate2530__c = 'No';
      
        
  for(ENT_NMTC_Distressed_Area_Association__c l : trigger.new)
        { 
        
           if(l.NMTC_Deal__c == 'Poverty Rates Greater Than 25 Percent')
           {
            deals[0].PovRate2530__c = 'Yes';
           
           }

        else

         {
             deals[0].PovRate2530__c = 'No';  
         }
        }
    update deals;    
}

 

This code executes but doesnt work...

As i have VF page on child object its not allowing me to save the record.

 

I feel its a lookup field (NMTC_Deal__c) so its not reading the value.. may be I am wrong.

 

Please help!!!!

 

bob_buzzard can u pls help??

  • December 28, 2012
  • Like
  • 0

Hi,

 

I need help in updating a parent record field with Yes or No value.

 

When I create a child record with lookup field value as hardcoded value, trigger get save but doesnt allow to save child record.

This is the code i am not able to save the child record. On child record I have visualforce page.

 

trigger PopulateDAA on DAA__c (after insert, after update)
{
    set<id> DealIDs = new set<id>();
    set<id> DdataIDs = new set<id>();
    
    for(DAA__c l : trigger.new)
    {
        DealIDs.add(l.Deal__c);
    }
   
    List<Deal__c> deals= [select id, PovRate2530__c from Deal__c where id in :DealIDs ];
    
      deals[0].PovRate2530__c = 'No';
      
        
  for(DAA__c l : trigger.new)
        { 
        
           if(l.Deal__c == 'Poverty Rates Greater Than 25 Percent')
           {
            deals[0].PovRate2530__c = 'Yes';
           
           }

        else

         {
             deals[0].PovRate2530__c = 'No';  
         }
        }
    update deals;    
}

 

This code executes but doesnt work...

As i have VF page on child object its not allowing me to save the record.

 

I feel its a lookup field (Deal__c) so its not reading the value.. may be I am wrong.

 

Please help!!!!

 

Hi friends, i m trying to call php webservice from apex.

 

can anyone help me??