• Syed Subhan 9
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 19
    Replies
I am implementing lightning:tabset and lightning:tab to display tabs in a lightning component. I have 2 tabs inside the tabset. I am trying to display error when user tries to fill tab 2 first by leaving tab 1 fields empty. Does anyone have any insight into how
 to achieve this functionality?
Hi,
I need to integrate quickbooks with salesforce using API's.
Can anyone help me the code to integrate.


 
.I need to query records from oportunity with checkbox next to each records. The functionality is, suppose I select 3 checkboxes i.e 3 records, I need to download detail pages of those 3 selected records by keeping a custom button. I need to achieve this functionality in lightning.  You can snap shot below. I need to select some multiple records and print the detail page information. Anyone with the Lightning code can help.
Thanks.User-added image
/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
public with sharing class CommunitiesSelfRegController {

    public String firstName {get; set;}
    public String lastName {get; set;}
    public String email {get; set;}
    public String password {get; set {password = value == null ? value : value.trim(); } }
    public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
    public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
    
    public CommunitiesSelfRegController() {}
    
    private boolean isValidPassword() {
        return password == confirmPassword;
    }

    public PageReference registerUser() {
    
           // it's okay if password is null - we'll send the user a random password in that case
        if (!isValidPassword()) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
            ApexPages.addMessage(msg);
            return null;
        }    

        String profileId = null; // To be filled in by customer.
        String roleEnum = null; // To be filled in by customer.
       <strong> String accountId = ''; // To be filled in by customer.</strong>
        
        String userName = email;

        User u = new User();
        u.Username = userName;
        u.Email = email;
        u.FirstName = firstName;
        u.LastName = lastName;
        u.CommunityNickname = communityNickname;
    u.ProfileId = profileId;
        
        String userId = Site.createPortalUser(u, accountId, password);
      
        if (userId != null) { 
            if (password != null && password.length() > 1) {
                return Site.login(userName, password, null);
            }
            else {
                PageReference page = System.Page.CommunitiesSelfRegConfirm;
                page.setRedirect(true);
                return page;
            }
        }
        return null;
    }
}

During the sites self-registration process, I have only come across the ability to create a portal user that creates both a contact and a user synchronously.  I would like to be able to create a portal user using an existing contact. 

Overall, need to create new user with existing contacts, i.e email id....Have to modity the default self registration controller.

Can any experts post the code in which you were able to enable new users under existing contact. It will help me alot...


 
Hi,
We have deployed the SF community, but when people use the self register link on the site SF creates a contact record and user record on a default account even if the email address matches a current customer.  As you can image managing the default account of contacts is not something I want to deal with.

During the sites self-registration process, I have only come across the ability to create a portal user that creates both a contact and a user synchronously.  I would like to be able to create a portal user using an existing contact.  I tried setting the contact id on the user object before I called createPortalUser, but it still created a new contact.  We are trying to eliminate the possibility of duplicate contacts.

So I am looking for a way to auto match users to their contacts to their user records if the email addresses match.  I understand that this can done with a controller.  I don't do that level of SF work yet, so any help would be great.


Can u post the code in which you were able to enable new users under existing contact. It will help me alot...

 
Requirement: There is a button "Export Today "  which is used to export account records in the form of csv in lightning component(Account_Detail_Component).In the helper ,we have "convertArrayOfObjectsToCSV" function which is used to convert object records into csv. I am able to display account fields values i.e 'Name','AccountNumber','Id'  in csv.But I am not able to display parent account field values.
For example below query return account field values and parent field value 
Select id,name,accountnumber,parent.accountnumber from Account where parent.id!=null and parent.accountnumber!=null.Could any one please post javascript code which needs to be used in helper fucntion for displaying parent  account records.


User-added image


Component:
<aura:component  controller="CsvDownloadCtrller" implements="force:appHostable">
    <aura:attribute name="AcctLst" type="Account[]"></aura:attribute>
    <aura:handler name="init" value="{!this}" action="{!c.loadAcctRcrds}"/>
    <div class="slds-box slds-box">
  <article class="slds-card">
  <div class="slds-card__header slds-grid">
    <header class="slds-media slds-media_center slds-has-flexi-truncate">
      
      <div class="slds-media__body">
        <h2 class="slds-card__header-title">
          <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Accounts">
            <span class="slds-text-heading_small">Account List View</span>
          </a>
        </h2>
      </div>
        
      <div class="slds-no-flex">
        <button class="slds-button slds-button_brand" onclick="{!c.exprtTodysRecrds}">Export Today</button>
        <button class="slds-button slds-button_brand">Export Weekly</button>  
      </div>
    </header>
  </div>
</article>
        
 <article class="slds-card">
  <div class="slds-card__header slds-grid">
    <header class="slds-media slds-media_center slds-has-flexi-truncate">
      
      <div class="slds-media__body">
        <h2 class="slds-card__header-title">
          <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Accounts">
            <span class="slds-text-heading_small">Search Accounts</span>
          </a>
        </h2>
      </div>
      
    </header>
  </div>
</article>
<div class="slds-form slds-form_compound">
    <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">
<div class="slds-form-element slds-size_1-of-2">
<lightning:select name="select1" label="Account Type" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
        <option value="4">four</option>
        <option value="5">five</option>
    </lightning:select>
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:input aura:id="field" label="Parent Account Number" name="ParentAccountNumber"  />
</div>
</div>
</div>
</fieldset>
<fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">
<div class="slds-form-element slds-size_1-of-2">
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:input aura:id="field" label="Account Number" name="AccountNumber"  />   
</div>    
</div>
</div>
</fieldset>
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">
    <lightning:textarea name="input1" label="Description" />    
</div>
<div class="slds-form-element slds-size_1-of-2">
<lightning:select name="select1" label="Country" required="true">
        <option value="">choose one...</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
         <option value="4">four</option>
    </lightning:select>  
</div>    
</div>
</div>
</fieldset> 
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2">    
</div>    
</div>
</div>
</fieldset>
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2">    
</div>    
</div>
</div>
</fieldset>          
 <fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">
        
</div>
<div class="slds-form-element slds-size_1-of-2"> 
    <lightning:input type="date" name="input1" label="From Date" /> 
</div>    
</div>
</div>
</fieldset>   
<fieldset class="slds-form-element">
<div class="slds-form-element__group">
<div class="slds-form-element__row">    
<div class="slds-form-element slds-size_1-of-2">        
</div>
<div class="slds-form-element slds-size_1-of-2"> 
    <lightning:input type="date" name="input1" label="To Date" /> 
</div>    
</div>
</div>
</fieldset>  
</div>
       
<div class="slds-no-flex slds-align_absolute-center slds-m-top_xx-large">
        <button class="slds-button slds-button_brand" style="width:100px">Search</button>
        <button class="slds-button slds-button_brand" style="width:100px">Clear</button>  
      </div> 
</div> 
</aura:component>

controller:
({
    loadAcctRcrds:function(component,event,helper){
        
       var action = component.get("c.getAccounts");
        action.setCallback(this,function(response){
        var state = response.getState();
            
            
            
            if(state == "SUCCESS"){
                
                component.set("v.AcctLst",response.getReturnValue());
                
            }
            else{
                alert('failed');
                
            }
        });
        $A.enqueueAction(action);      
        
    },
    
    exprtTodysRecrds : function(component, event, helper) {
         var stockData = component.get("v.AcctLst")    
         var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
          if (csv == null){return;} 
        
        // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####     
         var hiddenElement = document.createElement('a');
          hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
          hiddenElement.target = '_self'; // 
          hiddenElement.download = 'ExportData.csv';  // CSV file Name* you can change it.[only name not .csv] 
          document.body.appendChild(hiddenElement); // Required for FireFox browser
          hiddenElement.click(); // using click() js function to download csv file
        
        
    }
})


Helper:

({
        
    convertArrayOfObjectsToCSV : function(component,objectRecords){
        // declare variables
        var csvStringResult, counter, keys, columnDivider, lineDivider,parentKey;
       
        // check if "objectRecords" parameter is null, then return from function
        if (objectRecords == null || !objectRecords.length) {
            return null;
         }
        // store ,[comma] in columnDivider variabel for sparate CSV values and 
        // for start next line use '\n' [new line] in lineDivider varaible  
        columnDivider = ',';
        lineDivider =  '\n';
 
        // in the keys valirable store fields API Names as a key 
        // this labels use in CSV file header  
        keys = ['Name','AccountNumber','Id','Parent' ];
        //parentKey=['AccountNumber'];
        
        csvStringResult = '';
        csvStringResult += keys.join(columnDivider);
        csvStringResult += lineDivider;
 
        for(var i=0; i < objectRecords.length; i++){   
            counter = 0;
           
             for(var sTempkey in keys) {
                var skey = keys[sTempkey] ; 
                 
                /* if(skey=='Parent'){
                     for(var pTempkey in parentKey){
                         csvStringResult += '"'+ objectRecords[i][skey][pTempkey]+'"';                       
                         
                     }    
                     
                     
                 }*/
                
 
              // add , [comma] after every String value,. [except first]
                  if(counter > 0){ 
                      csvStringResult += columnDivider; 
                   }   
               
               csvStringResult += '"'+ objectRecords[i][skey]+'"'; 
               
                /* if(csvStringResult.includes("Parent")){
                     for(var sTemp in parentKey){
                         var orgnKey = parentKey[sTemp];        
                        csvStringResult += '"'+ objectRecords[i][skey][orgnKey]+'"'; 
                         
                     }
                     
                 } */ 
                 
                 
               
               counter++;
             
             } // inner for loop close     
             csvStringResult += lineDivider;
          }// outer main for loop close 
       
       // return the CSV formate String 
        return csvStringResult;        
    },

})

Apex Controller:

public class CsvDownloadCtrller {
    
    @AuraEnabled
    public static List<Account> getAccounts(){
       return [Select id,name,accountnumber,parent.accountnumber from Account where parent.id!=null and parent.accountnumber!=null];
              
        
    } 

}







 
Hi,
I need to integrate quickbooks with salesforce using API's.
Can anyone help me the code to integrate.


 
Hi,
We have deployed the SF community, but when people use the self register link on the site SF creates a contact record and user record on a default account even if the email address matches a current customer.  As you can image managing the default account of contacts is not something I want to deal with.

During the sites self-registration process, I have only come across the ability to create a portal user that creates both a contact and a user synchronously.  I would like to be able to create a portal user using an existing contact.  I tried setting the contact id on the user object before I called createPortalUser, but it still created a new contact.  We are trying to eliminate the possibility of duplicate contacts.

So I am looking for a way to auto match users to their contacts to their user records if the email addresses match.  I understand that this can done with a controller.  I don't do that level of SF work yet, so any help would be great.


Can u post the code in which you were able to enable new users under existing contact. It will help me alot...

 
For the community self registration page if the user enters the detail, I want to check if the contact already exist on the basis of email entered by user. If it does, I want to create user for that existing contact. How can achieve this?
Hi salesforce family,

followig functionality need to be achieved in below code.Please help me.

current functionality
----------------------------
1.)currently if we uncheck the check boxes of opportunitis and contacts and click submitt button all the contacts and opportunities records related to accounts are getting disappear.

required functionality
-----------------------------
1.)On uncheck the check boxs of opportunities and contacts with out clicking submitt button all the contacts and opportunities records related to accounts need to disappear.

2.)If we select the check boxs of opportunities and contacts with out clicking submitt button all the contacts and opportunities records related to accounts need to dispaly.

please try to achieve required functionality and also provide code coverage.

I here by providing code
=================
Apex class
---------------

public class Acc_con_Opp_Details
{
    
    //list of collection of the wrapper class object
    public list<accountwrapper> actwrap           {set;get;}
    //list of collection of Account,contact and opportunity objects
    public list<Account>        accounts          {set;get;}
    public list<Account>        acts              {set;get;}
    public list<opportunity>    opts              {set;get;}
    public list<opportunity>    sopts             {set;get;}
    public list<contact>        cnts              {set;get;} 
    public list<contact>        snts              {set;get;}
    public boolean oppbox                         {set;get;}//used as check box for opportunity 
    public boolean conbox                         {set;get;}//used as check box for contact
    public boolean flag1                          {set;get;}//used in account page block  
    public boolean flag2                          {set;get;}//used in contact page block 
    public boolean flag3                          {set;get;}//used in opportunity page block
    //this variables are used for pagination purpose
    private integer totalRecs = 0;//stores no.of total records   
    private integer index = 0;//used for tracking offset
    private integer blockSize =5;//for setting size of page
   
    //in this constructor we are setting values to boolean values
    public Acc_con_Opp_Details()
    {
    flag1=true;
    flag2=false;
    flag3=false;
        totalRecs = [select count() from Account];//returns total no.of account records 
       getactwrap();//calling getactwrap method.
    }
    //this method displays first five records
    public void beginning()
    {
        oppbox=false;
        conbox=false;
        index = 0;
        getactwrap();
    }
    //this method displays prevoius records
     public void previous()
    {
        oppbox=false;
        conbox=false;
        index = index-blockSize;
        getactwrap();
    }
    //this method displays next records
   public void next()
    {
        oppbox=false;
        conbox=false;
        index = index+blockSize;
        getactwrap();
    }
    //this method displays last remaining records
 public void end()
    {
        oppbox=false;
        conbox=false;
        index = totalrecs - math.mod(totalRecs,blockSize);
        getactwrap();
    }  
    //this variable is used to enable or disable first and previous buttons
 public boolean prev{get
    {
        if(index == 0)
        return true;
        else
        return false;
    }  set;}
    //this variable is used to enable or disable next and last buttons
 public boolean nxt{get
    {
        if((index + blockSize) > totalRecs)
        return true;
        else
        return false;
    }   set;}
    //used to display opportunities and contacts w.r.t selected accounts
    public void  submit()
    {
        flag1=false;
        acts=new list<Account>();
        for(accountwrapper aw:actwrap)
           {
            if(aw.acflag){
                acts.add(aw.acc);
           }
    }
        
        //if we select contact check box,then it displays contacts for selected accounts 
      if(conbox)
      {
      
              snts=[select id,lastName,Department,account.name from contact where accountid IN:acts];
              if(snts.size()>0)
              {
              flag3=true;
              }
              else
              {
              ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'contact records are not found for selected Accounts.'));
              }
         } 
        //if we select opportunity check box,then it displays opportunities for selected accounts
      if(oppbox)
        {
        
            
      opts=[select id,name,stageName,leadsource,account.name from opportunity where accountId IN:acts];
      if(opts.size() >0)
      {
      flag2=true;
      }
      else
       {
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'opportunity records are not found for selected Accounts.'));
       }
            } 
    }
   //it hides contacts and dispalys opportunitites on uncheck of contact check box
    public void Hideandshowopp()
    {
     
    if(oppbox==true)
    {
     flag2=true;
    }
    else
    {
     flag2=false;
    }
         
    }
   //  it hides opportunities and dispalys contacts on uncheck of opportunities check box 
     public void HideandshowCon()
    {
    if(conbox==true)
    {
     flag3=true;
    }
    else
    {
     flag3=false;
    }
         
    }
    
    //This method uses a simple SOQL query to return a List of Accounts
     public void getactwrap(){
         accounts = Database.Query('SELECT id,Name,phone FROM Account LIMIT :blockSize OFFSET :index');
         actwrap=new list<accountwrapper>();
       // As each Account is processed we create a new accountwrapper object and add it to the wrapper class(accountwrapper) list.
         for(account a:accounts)
        {
            actwrap.add(new accountwrapper(a));
        }
    }
    // this method  uses dml operation to edit the existing opportunities values or to insert new oppt values
    public void saveopps()
    {
        list<opportunity> opps=new list<opportunity>();
        opps.addAll(opts);
        upsert opps;
    }
    //his method  uses dml operation to edit the existing contact values or to insert new contact values
    public void savecons()
    {
       cnts = new list<contact>();
        cnts.addall(snts);
        upsert cnts;
    }
 //This is wrapper class which is collection of other class instances
  //here  wrapper class contains both the standard salesforce object Account and a Boolean value acflag   
 public class accountwrapper{
        public account acc{set;get;}
        public boolean acflag{set;get;}
             //In this contructor When we create a new accountwrapper object we pass a Account that is set to the acc property.
             // We also set the boolean value to false
        public accountwrapper(account a){
            acc=a;
            acflag=false;
        }
        
    }

}

vf page
----------
<apex:page controller="Acc_con_Opp_Details" showHeader="false" docType="html-5.0">
<apex:form >

    <!--This block dispalying account record details-->
    <apex:pageblock rendered="true">
    <apex:pageMessages ></apex:pageMessages>
    <apex:pageblocktable value="{!actwrap}" var="a">
        <apex:column >
    <apex:facet name="header" >Select</apex:facet>
             <apex:inputCheckbox value="{!a.acflag}"/>
        </apex:column>
        <!-- displays id,name and phone number for accounts-->
        <apex:column value="{!a.acc.id}"/>
        <apex:column value="{!a.acc.name}"/>
        <apex:column value="{!a.acc.phone}"/>
         </apex:pageblocktable>
        <!-- this buttons are used to paginate account records-->
        <apex:pageblockButtons >
            <!--displays first five records-->
            <apex:commandButton value="first"  action="{!beginning}" disabled="{!prev}"/>
            <!--displays previous records-->
            <apex:commandButton value="previous"  action="{!previous}" disabled="{!prev}"/>
             <!--displays previous  next records-->
            <apex:commandButton value="next"  action="{!next}" disabled="{!nxt}"/>
            <!-- displays last records-->
            <apex:commandButton value="last"  action="{!end}" disabled="{!nxt}"/>                                    
        </apex:pageblockButtons>
         <!-- check boxs for opportunities and contacts-->
        
     <center>  <apex:inputCheckbox value="{!oppbox}">
     <apex:actionSupport event="onchange" action="{!Hideandshowopp}"  rerender="block"/>
     </apex:inputCheckbox>Opportunities&nbsp;&nbsp;&nbsp;
         <apex:inputCheckbox value="{!conbox}">
         <apex:actionSupport event="onchange" action="{!HideandshowCon}" rerender="block"/>
         </apex:inputCheckbox>Contacts&nbsp;&nbsp;&nbsp;
        <apex:commandButton value="submit" action="{!submit}"/>
       </center>
    </apex:pageblock>
    <!--this block displays opportunity details-->
    <apex:pageblock rendered="{!flag2}" id="block" >
      
   <apex:pageblocktable value="{!opts}" var="o">
        
        <apex:column >
             <apex:facet name="header">Opportunity Id</apex:facet>
            <apex:commandlink value="{!o.id}" Action="{!URLFOR($Action.opportunity.edit,o.Id)}"/>
        </apex:column>
        <apex:column value="{!o.account.name}" />
        <apex:column >
            <apex:facet name="header">Opportunity Name</apex:facet>
       <apex:inputtext value="{!o.name}" />
            </apex:column>
        <apex:column >
           <apex:facet name="header">Opportunity Stage</apex:facet> 
       <apex:inputtext value="{!o.stagename}"/>
        </apex:column>
       <apex:column >
         <apex:facet name="header">Opportunity Leadsource</apex:facet> 
        </apex:column>
        </apex:pageblocktable>
        <apex:commandButton value="Save Opportunities" action="{!saveopps}"/>
    </apex:pageblock>
    <!--this block is used for displaying contact details -->
     <apex:pageblock rendered="{!flag3}">
         
     <apex:pageblocktable value="{!snts}" var="c">
        <apex:column >
            <apex:facet name="header">Contact Id</apex:facet>
            <apex:commandlink value="{!c}" Action="{!URLFOR($Action.contact.edit,c)}"/>
        </apex:column>
         <apex:column value="{!c.account.name}"/>
        <apex:column >
             <apex:facet name="header">Contact Lastname</apex:facet>
            <apex:inputtext value="{!c.lastname}"/>
        </apex:column>
        <apex:column >
        <apex:facet name="header">Contact Department</apex:facet>
            <apex:inputtext value="{!c.Department}"/>
        </apex:column>
        </apex:pageblocktable>
         <apex:commandButton value="Save Contacts" action="{!savecons}"/>
    </apex:pageblock>
   
    </apex:form>
</apex:page>
==============================================================================
 
Hi guys.. I want to integrate facebook on salesforce.i want to know the process regarding this.
I want to fetch some data regaring the user..
pls tell me what things are required as i am using REST api.
 
Hi friends,

I have 1 custom object (Dimensions__c) which has a lookup relationship with Account standard object (Dimensions__c is Child).

There is a chechbox on Dimension__c (Repayment_Enabled__c).

Now wehenever i create a dimension this check box is made true automatically.

What my need is that, there should be only one check box true on for a record related to account.
Even though there may be 5 dimension records which are related to 1 account but checkbox should be true for only 1 dimension record. 

I have tried this one, But struck.
As i am new to development Please help me.


trigger Primarycheck on Account (before insert,before update,after insert) {
List<Account> acct = new List<Account>();
    Set<Id> vwoid = new Set<Id>();
    List<Dimensions__c> vwo = new List<Dimensions__c>();   // my custom object
    for(Account a : trigger.new){
       if(Repayment_Enabled__c[0] == 'true'){   // this is the check box field which needs to be true for only one record related account
            Repayment_Enabled__c[1] = false;
        }
            }


How to solve this one.
Any help friends..!
        
        
    }
I'm getting connected to QB Online and authenticated, but now I'm trying to get a list of accounts.  I'm getting an invalid version on my return.

Here is the request that I'm using....
system.HttpRequest[Endpoint=https://sandbox-quickbooks.api.intuit.com/v3/company/13860xxxxx/query?query=SELECT * FROM Account, Method=GET]

The header is this:
OAuth oauth_consumer_key="qyprdkbWYESxxxxxxxxxxxxxH", oauth_nonce="-1898820638843667087", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1454507703", oauth_token="qyprdswhS3apsDvUS3HmHxxxxxxxxxxxxxxx7X0tKGxBj3oCmnU", oauth_version="1.0", Host="qbo.intuit.com", Connection="Keep-Alive", oauth_signature="rgnqOLJqe11xxxxxxxoyG82voyMg%3D"

And my response is:
System.HttpResponse[Status=Unknown Version, StatusCode=400]

I've tried taking the version out.  I've tried chainging it to 2.0 - I still get the same error.

​Any thoughts?
I am looking for an example to create a summary Report like data with subtotal and grandtotals in a visual force page in a PDF format. Please help.
I need  Integrate Quickbooks  with Salesforce .I'm done with one way integration(SF to QB Online),but i need QB online to SF.

Hi all,

 

So I've been searching for an answer but not come up with an answer so hoping the experts here can help.


Currently with Communities Self Registration the contact record related to the user which is created on registration is current linked to one account set in the CommunitiesSelfRegController (see below):

 

/**
 * An apex page controller that supports self registration of users in communities that allow self registration
 */
public with sharing class CommunitiesSelfRegController {

    public String firstName {get; set;}
    public String lastName {get; set;}
    public String email {get; set;}
    public String password {get; set {password = value == null ? value : value.trim(); } }
    public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
    public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
    
    public CommunitiesSelfRegController() {}
    
    private boolean isValidPassword() {
        return password == confirmPassword;
    }

    public PageReference registerUser() {
    
           // it's okay if password is null - we'll send the user a random password in that case
        if (!isValidPassword()) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
            ApexPages.addMessage(msg);
            return null;
        }    

        String profileId = null; // To be filled in by customer.
        String roleEnum = null; // To be filled in by customer.
        String accountId = ''; // To be filled in by customer.
        
        String userName = email;

        User u = new User();
        u.Username = userName;
        u.Email = email;
        u.FirstName = firstName;
        u.LastName = lastName;
        u.CommunityNickname = communityNickname;
    u.ProfileId = profileId;
        
        String userId = Site.createPortalUser(u, accountId, password);
      
        if (userId != null) { 
            if (password != null && password.length() > 1) {
                return Site.login(userName, password, null);
            }
            else {
                PageReference page = System.Page.CommunitiesSelfRegConfirm;
                page.setRedirect(true);
                return page;
            }
        }
        return null;
    }
}

 

My question is:  Has anybody modified the controller so an account is created for each contact when the user registers?

 

Thanks

Kev

Hi,

 

I'm in need of integrating QB with Salesforce using Apex code. For that, I have created a IPP account for Quickbooks API and created authendication between Quickbooks Online and intermediate application.

 

This Quickbooks API is used to integrate the Quickbooks Online and Salesforce through a custom Apex code and not to depend on any other third-party tool.

 

So, anyone help me how to call the response from the Quickbooks API to Salesforce through Apex code.

I searched may blogs and so, but I need the endurl to connect the QB API and SF.

 

If anybody used the same method to create apex callout to get the response from the QB API, it will be very useful.

 

 

Thanks in Advance,

Kamatchi Devi

 

 

During the sites self-registration process, I have only come across the ability to create a portal user that creates both a contact and a user synchronously.  I would like to be able to create a portal user using an existing contact.  I tried setting the contact id on the user object before I called createPortalUser, but it still created a new contact.  We are trying to eliminate the possibility of duplicate contacts.

  • April 07, 2011
  • Like
  • 0

Hi All,

 

I am trying to get visitors of a site to self-register as members using the customer portal. This is something I have done a few times now, but in this case is not working.

 

The logic I during self registration is as follows:

 

- create a user, user

- create an account of type person account

- insert the account

- change the account owner to a system admin with a role assigned

- update the account

- get the accountId

- make the following call --> ID userId = Site.createPortalUser(u, accountId, password);

 

The above call return userId=null, so that the customer portal user is not created.

 

I have tried to do "manually"what  the Site.createPortalUser call does internally and it works. What I have done is as follows:

 

- create a user, user

- create an account of type person account

- insert the account

- change the account owner to a system admin with a role assigned

- update the account

- get the accountId

- get the PersonContactId (since this is a Person Account)

- assiign  user.ContactId = PersonContactId

- assing user.profileId = (Id of the customer portal user profile)

- insert user

 

This gets me a valid userId and the person account is created and enabled for the customer portal okay.

 

On that basis I have tried again the call to  Site.createPortalUser but instead of the accountId tried passing the PersonContactId (since it is a person account) and this did not work.

 

Any ideas would be very much appreciated.

 

Thanks in advance

 

Hi all.  Quick question: is there any way to access the content of a static resource from Apex code?

I know how to access the resource inside VF markup (URLFOR, $Resource); what I'm trying to do here is get at the contents of an XML or text file resource from within an Apex method.

I couldn't find an API for doing this.  The only thing I could think of was to do an HTTP callout, but that seems to give me a 404 no matter what I do; I gather there is a proxy back there that has a different view of the world than my browser does.

Is there a better way to go about this?

Thanks very much,
-p

  • August 29, 2008
  • Like
  • 0