• Craig P
  • NEWBIE
  • 0 Points
  • Member since 2011

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

We have an application built using custom objects that we would like to expose to our partners using the "Authenticated Website" license. According to the documentation, we should be able to expose custom objects (read/write) to users w/ the Authenticated Website license, however there is not an intuitive path to follow to set this up.

 

Specifically:

   1) should the user w/ the Authenticated Website license access the application via the Customer Portal? or through a Force.com Site?

   2) how do we modify permissions to custom objects for the "Authenticated Website" profile? (the custom objects are not listed in the Profile page)

I am trying to use the JSON.deserialize() and it is not working. 

    public class MemberProfile {
        public Integer Id { get; set; }
        public String first_name { get; set; }
        public String last_name { get; set; }
        public String email { get; set; }
    }

 

.

in my class....

 

MemberProfile memberProfile = (MemberProfile) JSON.deserialize(httpResponse.getBody(), MemberProfile.class);

 Error = Compile Error: Variable does not exist: MemberProfile.class

 

 

 

 

I have a VF page that lists members of a campaing.  Within in each row, I want the user to be able to click on a button to log an activity.

 

I have a RemoteAction method working fine, if it is invoked from an HTML element outside of the pageBlockTable.  However, when the RemoteAction is invoked from a button in a row in the pageBlockTable, it does not work.  Am I missing somthing obvious?

 

Class w/ RemoteAction - works fine when invoked from a button outside of a pageBlockTable

global with sharing class CampaignConsoleRemoteController {

    public String contactOrLeadId{ get; set; }
    public static Contact contact { get; set; }    

    /*******************************************************************************
    *    empty constructor...
    *******************************************************************************/
    public CampaignConsoleRemoteController(CampaignConsoleController controller) {}

    /*******************************************************************************
    *    remote method to add Activity for the Campaign Member...
    *******************************************************************************/
    @RemoteAction
    global static String addActivityHistory(String contactOrLeadId) {
        Task t = new Task();
        t.subject = 'Campaign call';
        t.type = 'Call';
        t.status = 'completed';
        t.activitydate = system.today();
        t.description = 'words words words';
        t.whoId = contactOrLeadId;
        //CE:  t.whatId = account.Id;
        insert t;        
                   
        return contactOrLeadId;
    }
}

 

Visualforce page...

<apex:page controller="CampaignConsoleController" extensions="CampaignConsoleRemoteController" action="{!getData}" id="ccPage">
    <script type="text/javascript">
        /*******************************************************************
        *     addActivityToCampaignMember(contactLeadId, noteElementId)
        *******************************************************************/
        function addActivityToCampaignMember(contactLeadId) {
            // debug info...
            console.log("contactLeadId: ", contactLeadId);
    
            // invoke the remote action on the server...
            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.CampaignConsoleRemoteController.addActivityHistory}',
                contactLeadId, 
                function(result, event){
                      if( event.status ) {
                          // Get DOM IDs for HTML and Visualforce elements like this
                          console.log("inside anonymous function... result Id: ", result);                          
                          console.log("result Id: ", result);
                          document.getElementById("cepInput").innerHTML = result;
                      } else if (event.type === 'exception') {
                          document.getElementById("responseErrors").innerHTML = 
                          event.message + "<br/>\n<pre>" + event.where + "</pre>";
                      } else {
                          document.getElementById("responseErrors").innerHTML = event.message;
                      }
                }, 
                {escape: true}
            );        
            
            console.log("finishing JS function...");
        }
    </script>
 
    <body id="ccBody">
        <apex:sectionHeader title="Campaign Console"></apex:sectionHeader>
        <apex:form id="ccForm" >
           <!-- display error messages... -->
           <apex:pageMessages />
           <!-- display Contacts that are Campaign Members... -->
            <apex:pageBlock title="Contacts" id="ccPageBlock">
                <apex:pageBlockTable value="{!CampaignMemberContacts}" var="cm" id="ccPageBlockTable">
                   <apex:column rendered="false">
                        <apex:inputHidden value="{!cm.Contact.Id}" Id="memberId" />
                   </apex:column>
                   <apex:column headerValue="Company Name" value="{!cm.Contact.Account.name}" />
                   <apex:column value="{!cm.Contact.name}"/>
                   <apex:column value="{!cm.Contact.phone}"/>
                   <apex:column value="{!cm.Contact.email}" />
                   <apex:column headerValue="Status">
                       <apex:inputField value="{!cm.Status}"  onchange="updateRecords();" />
                   </apex:column>
                   <apex:column headerValue="Note"  >
                       <apex:inputTextArea value="{!note}" Id="ccContactNote" />
                   </apex:column>
                   <apex:column >
                       <!-- <apex:commandButton id="btnAddNote" value="Add Note" onclick="saveRow(jQuery(this).closest('tr').prevAll('tr').length, '{!cm.Contact.Id}')" /> -->
                       <!-- <apex:commandButton id="btnAddNote" value="Log Activity" onclick="saveRow('1', '{!cm.Contact.Id}', '{!$Component.ccContactNote}')" /> -->
                       <apex:commandButton id="btnAddNote" value="Log It!" onclick="addActivityToCampaignMember('{!cm.Contact.Id}')" />
                   </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:form>    
    </body>    
</apex:page>

 

I have a custom button on the Contact object which uses a Visualforce page to send an email and create a Task.  It is working fine.

 

Requirement:

I need to add a confirmation (e.g., "are you sure you want to send an email?") to the button, but I cannot use JavaScript on the button itself because I am invoking a Visualforce page.

 

Also, I cannot add JavaScript to the Visualforce page, because I am using the action attribute on the <apex:page> element

 

Is there a way to automatically invoke a JavaScript function from the <apex:page> element?  Is there any way to have a JavaScript confirm on a custom button that is using a Visualforce page?

 

Thanks in advance!

  • September 26, 2012
  • Like
  • 0

I added a custom lookup field (Product__c) to the Lead object and need to map it to the Opportunity standard field.  I have the code to add the Pricebook Entry to the Opportunity Line Item, but I cannot get the Product2Id from my custom lookup field (Lead.Product__c)

 

How do I get the Product ID (or Pri

 

 

trigger trgLeadConvert on Lead (after update)

{   

    for(Lead l : Trigger.new) 

    {       

           if(l.IsConverted && l.convertedOpportunityId != null)       

          {           

                     Opportunity oppty = [Select o.Id, o.Description from Opportunity o Where o.Id = :l.ConvertedOpportunityId];                           

                     // add an opportunity line item...           

                     OpportunityLineItem oli = new OpportunityLineItem();           

                     oli.OpportunityId = oppty.Id;           

                     oli.Quantity = 1;           

                     oli.TotalPrice = 100.00;           

                     

                     // THIS IS I NEED HELP!!!!

                     //oli.PricebookEntryId = l.Product__c.PricebookEntry.Product2Id;           

                     //oli.PricebookEntryId = l.Product__c.Id;           

 

                     insert oli;
       }   

}

}

Does anyone have a basic primer/how to for setting up an Authenticated Website user? SFDC support has not been able to help after multiple cases that have been opened.

  • April 22, 2013
  • Like
  • 0

I have a custom button on the Contact object which uses a Visualforce page to send an email and create a Task.  It is working fine.

 

Requirement:

I need to add a confirmation (e.g., "are you sure you want to send an email?") to the button, but I cannot use JavaScript on the button itself because I am invoking a Visualforce page.

 

Also, I cannot add JavaScript to the Visualforce page, because I am using the action attribute on the <apex:page> element

 

Is there a way to automatically invoke a JavaScript function from the <apex:page> element?  Is there any way to have a JavaScript confirm on a custom button that is using a Visualforce page?

 

Thanks in advance!

  • September 26, 2012
  • Like
  • 0

I'm struggling a little to find the necessary documentation to get started using the Authenticated Website profile & user licenses type.  How do I create new users?  Is the only way to do that is to create the user using Apex?  We don't need (or want) self-registeration in our use case -- we really want the bare minimum "user get username and password & is able to login..."

 

Ideally this is probably just a simple recipe and I'd be ready to go -- but I'm struggling figuring that out, even though I think it should be easy over all.

 

Michael

  • On the Lead object, I created a custom field called “Product_1__c”, which is a Lookup field to the Product object
  • I have successfully created a trigger that moves the Product from the Lead to the Opportunity during the Convert process

 

Problem:  In my Apex test class, how do I programmatically add the custom field “Product_1__c” to the Lead, and then invoke the Convert process?

 

Apex Unit Test code:

@isTest

private class testTrgLeadConvert {
    static testMethod void myUnitTest() {       

test.startTest();               

 

// Create the Lead object...

Lead lead = new Lead();       

lead.LastName = 'Test LastName';       

lead.Company = 'Test Company';       

insert lead;               

 

// make an update....

lead.Status = 'Qualified Lead';       

lead.Number_of_Reps__c = 10;       

lead.Industry = 'Banking';       

update lead;               

 

// test to ensure update worked...

Lead updatedLead = [SELECT Id, LastName, Company, Status, Industry FROM Lead Where Id = :lead.Id];       

System.assertEquals('Banking', updatedLead.Industry);               

 

// convert the Lead...

Database.Leadconvert leadConvert = new Database.Leadconvert();       

leadConvert.setLeadId(updatedLead.Id);       

leadConvert.setConvertedStatus('Qualified Lead');       

leadConvert.setDoNotCreateOpportunity(false);       

leadConvert.setSendNotificationEmail(false);               

Database.Leadconvertresult lcr = Database.convertLead(leadConvert);       

System.debug('leadConvert' + lcr.isSuccess());

 

Opportunity o = [SELECT Id, OwnerId FROM Opportunity WHERE Id=:lcr.getOpportunityId()];    

System.debug('opportunity ID:  ' + o.Id);        test.stopTest();   

}

}

 

Trigger:

trigger trgLeadConvert on Lead (after insert, after update) {
// products & opportunities   

set<Id> products = new Set<Id>();   

set<id> opportunities = new set<id>();             

 

// product to pricebook entries   

map<id,pricebookentry> pricebookentries = new map<id,pricebookentry>();             

 

// line items to add   

list<opportunitylineitem> lineitems = new list<opportunitylineitem>();             

 

// standard pricebook   

pricebook2 standardpricebook = [select id from pricebook2 where isstandard = true];
   

// get all of the Lead object's product and opportunity id values    

for(lead l : trigger.new) {       

products.add(l.Product_1__c);       

products.add(l.Product_2__c);       

products.add(l.Product_3__c);       

products.add(l.Product_4__c);       

opportunities.add(l.convertedopportunityid);   

}
   

// map product id to pricebook entry...  join the Lead's Product w/ the Pricebook Entry   

for(pricebookentry pbe:[select id, unitprice, product2id                            

  from pricebookentry                            

  where pricebook2.isstandard = true                              

     and product2id in :products]) {       

pricebookentries.put(pbe.product2id, pbe);   

}
   

// set pricebook entry value for opportunities   

for(opportunity[] opps:[select id from opportunity where id in :opportunities]) {       

for(opportunity opp:opps) {           

opp.pricebook2id = standardpricebook.id;       

}       

update opps;   

}
   

// create line items   

for(lead l:trigger.new) {       

if(l.convertedopportunityid == null || l.Product_1__c == null) continue;       

lineitems.add(new opportunitylineitem(quantity=1,totalprice=pricebookentries.get(l.Product_1__c).unitprice,opportunityid=l.convertedopportunityid,pricebookentryid=pricebookentries.get(l.Product_1__c).id));               if(l.Product_2__c == null) continue;       

lineitems.add(new opportunitylineitem(quantity=1,totalprice=pricebookentries.get(l.Product_2__c).unitprice,opportunityid=l.convertedopportunityid,pricebookentryid=pricebookentries.get(l.Product_2__c).id));
       if(l.Product_3__c == null) continue;       

lineitems.add(new opportunitylineitem(quantity=1,totalprice=pricebookentries.get(l.Product_3__c).unitprice,opportunityid=l.convertedopportunityid,pricebookentryid=pricebookentries.get(l.Product_3__c).id));
       if(l.Product_4__c == null) continue;       

lineitems.add(new opportunitylineitem(quantity=1,totalprice=pricebookentries.get(l.Product_4__c).unitprice,opportunityid=l.convertedopportunityid,pricebookentryid=pricebookentries.get(l.Product_4__c).id));}     

// commit line items to the database   

insert lineitems;    

 

}

 

 

 

 

I added a custom lookup field (Product__c) to the Lead object and need to map it to the Opportunity standard field.  I have the code to add the Pricebook Entry to the Opportunity Line Item, but I cannot get the Product2Id from my custom lookup field (Lead.Product__c)

 

How do I get the Product ID (or Pri

 

 

trigger trgLeadConvert on Lead (after update)

{   

    for(Lead l : Trigger.new) 

    {       

           if(l.IsConverted && l.convertedOpportunityId != null)       

          {           

                     Opportunity oppty = [Select o.Id, o.Description from Opportunity o Where o.Id = :l.ConvertedOpportunityId];                           

                     // add an opportunity line item...           

                     OpportunityLineItem oli = new OpportunityLineItem();           

                     oli.OpportunityId = oppty.Id;           

                     oli.Quantity = 1;           

                     oli.TotalPrice = 100.00;           

                     

                     // THIS IS I NEED HELP!!!!

                     //oli.PricebookEntryId = l.Product__c.PricebookEntry.Product2Id;           

                     //oli.PricebookEntryId = l.Product__c.Id;           

 

                     insert oli;
       }   

}

}