• Rony57
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 17
    Replies
Hi All,
         I am bit confused  about this error. i have made all the  things while make this . Anybody help me out ?
trigger MatchTrigger on Match__c (after insert, after update, after delete, before delete)
 {

     if (Trigger.isAfter && (Trigger.isInsert || Trigger.isDelete))
    {
       System.debug('*** Started calculation matches: ' + Trigger.new);
        Set<Id> aDemandIdSet = new Set<Id>();
         Set<Id> aSupplyIdSet = new Set<Id>();
         //Find all the properties involved in changes matches.
        for (Match__c aMatch : Trigger.isInsert ? Trigger.new : Trigger.old)
        {
            if (aMatch.Supply__c != null)
            {
                aSupplyIdSet.add(aMatch.Supply__c);
            }
            if (aMatch.Demand__c != null)
            {
                aDemandIdSet.add(aMatch.Demand__c);
            }
        }
     //Perform search for count of matches in two types: when Property is set as Property1__c in match object
        //and when it was set as EnquiringProperty__c.
        List<AggregateResult> aMatchCountResult = [SELECT COUNT_DISTINCT(Demand__c) counter, Supply__c FROM Match__c WHERE Supply__c IN :aSupplyIdSet GROUP BY Supply__c];
        List<AggregateResult> aMatchCountResult2 = [SELECT COUNT_DISTINCT(Supply__c) counter, Demand__c FROM Match__c WHERE Demand__c IN :aDemandIdSet GROUP BY Demand__c];
        Map<Id, Supply__c> anUpdateMap = new Map<Id, Supply__c>();
         Map<Id, Demand__c> anUpdateMap1 = new Map<Id, Demand__c>();
        
        //Calculate total count as sum of two values.
        for (AggregateResult anAgrRes : aMatchCountResult)
        {
            Id anId = (Id) anAgrRes.get('Supply__c');
            if (anId!= null)
            {
                System.debug('*** Result count for Id ' + anId + ': ' + anAgrRes.get('counter'));
                anUpdateMap.put(anId, new Supply__c(Id = anId, MatchedProperties__c = (Decimal)anAgrRes.get('counter')));
            }
        }
        for (AggregateResult anAgrRes : aMatchCountResult2)
        {
            Id anId = (Id) anAgrRes.get('Demand__c');
            if (anId != null)
            {
                System.debug('*** Result2 count for Id ' + anId + ': ' + anAgrRes.get('counter'));
                Demand__c aProp = anUpdateMap1.get(anId);
                if (aProp == null)
                {
                    aProp = new Demand__c(Id = anId, MatchedProperties__c = 0);
                    anUpdateMap1.put(anId, aProp);
                }
                aProp.MatchedProperties__c += (Decimal)anAgrRes.get('counter');
            }
        }
        //For all the rest propertis set count as 0.
        for (Id aPropId: aSupplyIdSet)
        {
            if (!anUpdateMap.containsKey(aPropId))
            {
                anUpdateMap.put(aPropId,  new Supply__c(Id = aPropId, MatchedProperties__c = 0));
            }
        }
        System.debug('*** Uptdate Matches count for Properties: ' + anUpdateMap.values());
        update anUpdateMap.values();
    }
        /**
        Share a new match.
    */
    if(Trigger.isInsert && Trigger.isAfter)
    {
        // We only execute the trigger after a Match record has been inserted 
        // because we need the Id of the Match record to already exist.
        // Match_Share is the "Share" table that was created when the
        // Organization Wide Default sharing setting was set to "Private".
        // Allocate storage for a list of Match__Share records.
        List<Match__Share> matchShares  = new List<Match__Share>();
        
        // For each of the Match records being inserted, do the following:
        for (Match__c match : trigger.new)
        {
            // Create a new Match__Share record to be inserted in to the Match_Share table.
            Match__Share matchBrokerShare = new Match__Share();
                
            //Populate the Match__Share record with the ID of the record to be shared.
            matchBrokerShare.ParentId = match.Id;
                
            // Then, set the ID of user or group being granted access. In this case,
            // we’re setting the Id of the Hiring Manager that was specified by 
            // the Recruiter in the Hiring_Manager__c lookup field on the Match record.  
            // (See Image 1 to review the Match object's schema.)
            matchBrokerShare.UserOrGroupId = match.Match_Property_Broker__c;
                
            // Specify that the Hiring Manager should have edit access for 
            // this particular Match record.
            matchBrokerShare.AccessLevel = 'edit';
            // Specify that the reason the Hiring Manager can edit the record is 
            // because he’s the Hiring Manager.
            // (Hiring_Manager_Access__c is the Apex Sharing Reason that we defined earlier.)
            matchBrokerShare.RowCause = Schema.Match__Share.RowCause.Suggested_Property_Broker__c;
                
            // Add the new Share record to the list of new Share records.
            
            matchShares.add(matchBrokerShare);
        }
        // Insert all of the newly created Share records and capture save result 
        Database.SaveResult[] matchShareInsertResult = Database.insert(matchShares, false);
        for(Database.SaveResult aSaveRes: matchShareInsertResult)
        {
            if(!aSaveRes.isSuccess())
            {
                Database.Error[] anErrors = aSaveRes.getErrors();
                for (Database.Error anError: anErrors)
                {
                    System.debug('*** Got an error on insert Deal sharing: ' + anError.getMessage());
                }
            }
        } 
    }
    
    /**
        If we change match Interested_in_Dealing__c  status to true, a new deal will be created.
    */
    if (Trigger.isUpdate && Trigger.isAfter)
    {
        // A new record is created on Deal object like opportunity created between both the Property Record owners on one match
        // if they wish to work together. it is triggerd by field Interested in dealing when checked by either of the record owner.
        List<Deal__c> dealsList = new List<Deal__c>();
        for(Match__c aMatchObject: Trigger.new)
        {
            Match__c anOldMatch = Trigger.oldMap.get(aMatchObject.Id);
            //Check if match is set as interested and both properties are available.
            if (aMatchObject.Interested_in_Dealing__c == true
                      && anOldMatch.Interested_in_Dealing__c == false
                      && (aMatchObject.Status_Match__c == 'Available' || aMatchObject.Status_Match__c == 'Duplicate')
                      && (aMatchObject.Demand_Status_Match__c == 'Available' || aMatchObject.Demand_Status_Match__c == 'Duplicate'))
            {
                //Create new deal for such properties and match object.
                 
                Deal__c newOpportunity = new Deal__c(); 
                newOpportunity.Name = aMatchObject.Name + 'On' + aMatchObject.Id + '-' + aMatchObject.Supply__c;
                newOpportunity.Close_Date__c = Date.today().addDays(30);
                newOpportunity.Stage__c = 'Shortlisted'; 
                newOpportunity.Match__c = aMatchObject.Id;
                newOpportunity.Demand__c = aMatchObject.Demand__c;
                newOpportunity.Supply__c= aMatchObject.Supply__c;
                dealsList.add(newOpportunity);
                System.debug('*** Create new deal: ' + newOpportunity);
                
            }
        }
        insert dealsList;
    }
            
            /**
        When we remove the match object, the related deal will be also deleted.
    */
    if (Trigger.isBefore && Trigger.isDelete)
    {
        List<Deal__c> aDeleteDeals = new List<Deal__c>();
        //Find all deals for the removed matches
        List<Deal__c> aFullList = [SELECT Id, Stage__c FROM Deal__c WHERE Match__c IN :Trigger.oldMap.keySet()];
        for (Deal__c aDeal: aFullList)
        {
            if (aDeal.Stage__c != 'Deal Closed Won')
            {
                aDeleteDeals.add(aDeal);
            }
        }
        System.debug('Remove deals: ' + aDeleteDeals);
        delete aDeleteDeals;
   }
      }

 
  • April 16, 2015
  • Like
  • 0
Hello All,
               I  want to make a Trigger  to match the Product  , like there are three  objects demand , supply and matches. Some fileds are there in demand  like product  ,product  type  and same in the supply ..  Demand consits of   piclist   buy and supply consists of piclist  Sell. I just want to make a trigger  to match the Sell----> buy and Buy---->Sell ,  there is a status field  also in both demand and supply object  and  whene ever a status  is "Available" the product  will match in match object .

Any help would be appreciated . Thanx
  • April 03, 2015
  • Like
  • 0
Hello All,
            I have written code in apex and visualforce  to saving the Geo location in my detail page. While doing this an error is coming on this particular line.It throw an error on my particular this code:
 
newSupply.GeoLocation__Latitude__s=decimal.valueOf(latitude);
newSupply.GeoLocation__Longitude__s=decimal.valueOf(longitude);
"Visualforce Error System.Type Exception: Invalid decimal".
 
  • March 30, 2015
  • Like
  • 0
Hello All,
             I had wrote a script to use the google map in Vf page. I want to use i want to use the autocomplete  city text box. Can you help me out Guys.

Here is my script
<script>
var marker=null ;
var map=null ; 
function initialize() {  
       
     var positioninit = new google.maps.LatLng('{!latitude}', '{!longitude}');     
     var mapOptions = {
        zoom: 4,
        center: positioninit,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };     
    map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    if('{!latitude}' != '' && '{longitude}' != ''){
        placeCoordinate(positioninit);
    }
} 
google.maps.event.addDomListener(window, 'load', initialize);
function saveLocation(){
    $('.latitudeField').val(marker.position.lat());
    $('.longitudeField').val(marker.position.lng());
    saveAccount();
}
function showLocation(){
    alert('Latitude: ' + marker.position.lat() + '\nLongitude: ' + marker.position.lng());
}
function searchAddr(){
    var addrInput = document.getElementById('id_city');
    new google.maps.Geocoder().geocode( { 'address': addrInput.value}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
        placeCoordinate(results[0].geometry.location);
        addrInput.value = results[0].formatted_address;  
        saveLocation();      
    } else {
        alert("Geocode was not successful for the following reason: " + status);
    }
    });
}
function placeCoordinate(location){
    if(!marker){
        marker = new google.maps.Marker({
            map: map,
            draggable: true
        });
        google.maps.event.addListener(marker, 'click', showLocation);
    }
    marker.setPosition(location);
    map.setCenter(location);
    map.setZoom(15);
}
</script>

 
  • March 28, 2015
  • Like
  • 0
Hello Guys  i am stuck in the google map while using it in VF page . I need to  locate the city along with the street adress on the google map and   draw radius when ever user click on  the search button . My Autocomplete textbox is working  . I need to add the seach functionality  on the seach button.
Here is my code:-
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
<script type="text/javascript">
        var map;
        
function initializeField() {
var input = document.getElementById('page:frm:field');           
var autocomplete = new google.maps.places.Autocomplete(input); 
var mapOptions = {
zoom:6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,

center: new google.maps.LatLng(20.593684,78.962880)
};
map = new google.maps.Map(document.getElementById('MyMap'),
  mapOptions);
}
google.maps.event.addDomListener(window, 'load', initializeField);

</script>


 <input type="button" class="btn customBtn pull-right"  value="Search" />

Help me out
  • March 25, 2015
  • Like
  • 0
Hello Guys,
                I have wrote a trigger on account object that  whenever a user enter duolicate  phone number or email then it will show an error on page and the info will not stored in the account object.
Here is the code
trigger AccountTrigger on Account (before insert, before update)
{
    //Account duplicate protection system.
    if (Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate))
    {
        Map<String, Account> anAccountMap = new Map<String, Account>();
        for (Account anAccount : System.Trigger.new)
        {
            // Make sure we don't treat an mobile phone that  
            // isn't changing during an update as a duplicate.  
            if ((anAccount.Phone != null) && (Trigger.isInsert || 
                      (anAccount.Phone != Trigger.oldMap.get(anAccount.Id).Phone)))
            {
                // Make sure another new Account isn't also a duplicate  
                if (anAccountMap.containsKey(anAccount.Phone))
                {
                    anAccount.Phone.addError('Another new Account has the same mobile phone.');
                    System.debug('*** Error: found account with dublicate mobile phone: ' + anAccount);
                } else
                {
                    anAccountMap.put(anAccount.Phone, anAccount);
                }
            }
        }  
        // Using a single database query, find all the Accounts in  
        // the database that have the same mobile phone as any  
        // of the Accounts being inserted or updated.  
        for (Account aDBAccount : [SELECT Phone FROM Account WHERE Phone IN :anAccountMap.KeySet()])
        {
            Account newAccount = anAccountMap.get(aDBAccount.Phone);
            newAccount.Phone.addError('An Account with this mobile phone already exists.');
            System.debug('*** Error: found account with dublicate mobile phone: ' + newAccount);
        }
    }
}
Note:-- The thing is that its working but  its not showing any erorr on my particular page. Any help from the MVP's or the consultant  will be great.
Thanx
 
  • March 23, 2015
  • Like
  • 0
Hello All please pay attention to this  I have a autocomplete vf page  in which the  one text box is there search account name. i want that whenever the user enter  the name  then the name should come along with his phone number.. right now  only number is coming /Below is the  VF  code and controller code
Vf page:- 
<apex:page controller="AutoCompleteController" >
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js" />
    <apex:styleSheet value="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css" />
    
    <style>
        .displayNone { 
            display:none; 
        }
        .displayBlock {
            display:block;
        }
        .ui-autocomplete-loading { 
            background: white url(/img/loading32.gif) right center no-repeat;
            background-size:15px 15px; 
        }
        .placeHolder {
            font-style: italic;
        }
    </style>
    
    <apex:form id="autoCompleteForm" >
        
        <apex:pageBlock id="searchBlock" >
            <apex:pageBlockSection id="searchSection" title="Search Your Account" columns="1" >
                 <apex:outputLabel value="Account Name" for="AccountBox" />
                 <apex:outputPanel >
                     <apex:inputText id="AccountTextBox" value="{!searchTerm}" styleClass="placeHolder"/>
                     <apex:inputHidden id="searchAccountId" value="{!selectedAccount}" />
                 </apex:outputPanel>
            </apex:pageBlockSection>
        </apex:pageBlock>
        
    </apex:form>
    
    <script type="text/javascript">
        var PLACEHOLDER = 'Enter Account Name Here'; 
        var AccountObjects;
        var queryTerm;
        $('[id$=AccountTextBox]').autocomplete({
            minLength: 2,
            source: function(request, response) {
                        queryTerm = request.term;
                        AutoCompleteController.searchAccount(request.term, function(result, event){
                            if(event.type == 'exception') {
                                  alert(event.message);
                            } else {
                                 AccountObjects = result;
                                 response(AccountObjects );
                            }
                        });
                   },
            focus: function( event, ui ) {
                    $('[id$=AccountTextBox]').val( ui.item.Name );
                    return false;
                    },
            select: function( event, ui ) {
                        $('[id$=AccountTextBox]').val( ui.item.Name );
                        $('[id$=AccountTextBox]').val( ui.item.Phone);
                        $('[id$=searchAccountId]').val( ui.item.Id );
                        return false;
                    },
         })
         .data( "autocomplete" )._renderItem = function( ul, item ) {
            var entry = "<a>" + item.Name;
             var entry = "<a>" + item.Phone;
           
            entry = entry + "</a>";
            entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>");
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( entry )
                .appendTo( ul );
        };
            
        // Add or remove placeholder values
        $('[id$=AccountTextBox]').val(PLACEHOLDER);
        $('[id$=AccountTextBox]').on("focus",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === PLACEHOLDER ){
                $tgt.val('');
                $tgt.removeClass('placeHolder');
            }
        });
        $('[id$=AccountTextBox]').on( "blur",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === '' ){
                $tgt.val(PLACEHOLDER);
                $tgt.addClass('placeHolder');
            }
        });
    </script>
</apex:page>
Controller:-
public with sharing class AutoCompleteController {
    
    // Instance fields
    public String searchTerm {get; set;}
    public String selectedAccount {get; set;}
    
    // Constructor
    public AutoCompleteController() {
        
    }
    
    // JS Remoting action called when searching for a account name
    @RemoteAction
    public static List<Account> searchAccount(String searchTerm) {
        System.debug('Account Name is: '+searchTerm );
        List<Account> Account= Database.query('Select Id, Name, Phone from Account where name like \'%' + String.escapeSingleQuotes(searchTerm) + '%\'');
        return Account;
    }
    
}
  • March 17, 2015
  • Like
  • 0
Hi All,
I have wrote some code for range slider in VF and I have little bit knowledge in JS. My question is
1. I want to change step based on some criteria for min value and max values. In my code step is working proper for max value but step for min value is not working.
2. And i want to change dynamic value  for slider. if min value is 10000 then max value should be 50000.
pls help me out

//my code is------------

 
<apex:page >
<head>
<apex:stylesheet value="{!URLFOR($Resource.bootstrap_SFOne,'bootstrap-sf1/dist/css/bootstrap.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.SliderCSSJS,'jquery/jquery-ui-1.7.2.custom.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.SliderCSSJS,'jquery/jquery-1.3.2.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.SliderCSSJS,'jquery/jquery-ui-1.7.2.custom.min.js')}"/>
<script type="text/javascript">
$(document).ready(function(){            
            $("#slider-range").slider({                
                range: true,                
                min: 0,
                max: 20000000,
                step: 1000,
                values: [0,1000000],
                slide: function(event, ui){                                     
                    $("#minBudget").html('$' + $("#slider-range").slider("values", 0));           
                    $("#maxBudget").html('$' + $("#slider-range").slider("values", 1));
                    var step = $('#slider-range').slider('option', 'step');                                     
                    
                    if(ui.values[0]<50000){
                        $('#slider-range').slider('option', 'step', 5000);
                    }else{
                        $('#slider-range').slider('option', 'step', 10000);
                    }
                    if(ui.values[1]<50000){
                        $('#slider-range').slider('option', 'step', 5000);
                    }else if(ui.values[1]>=50000 && ui.values[1]<100000){
                        $('#slider-range').slider('option', 'step', 10000);
                    }else if(ui.values[1]>=100000 && ui.values[1]<2500000){                    
                        $('#slider-range').slider('option', 'step', 100000);
                    }else if(ui.values[1]>=2500000 && ui.values[1]<5000000){                    
                        $('#slider-range').slider('option', 'step', 200000);
                    }else if(ui.values[1]>=5000000 && ui.values[1]<10000000){                    
                        $('#slider-range').slider('option', 'step', 500000);
                    }else{
                        $('#slider-range').slider('option', 'step', 1000000);
                    }
                }                
            });            
            $("#minBudget").html('$' + $("#slider-range").slider("values", 0));           
            $("#maxBudget").html('$' + $("#slider-range").slider("values", 1));         
        });
</script>
</head>
<body>
<div id="slider-range" style="font-size: 90%; margin-top: 5em;"></div>
<div id="minBudget" style="margin-top: 1.5em;float:left"></div>
<div id="maxBudget" style="margin-top: 1.5em;float:right"></div>

</body>
<style type="text/css">
.ui-slider-horizontal .ui-slider-handle {
    top: -0.75em;
} 
.ui-slider .ui-slider-handle{
    height:2em;
    border-radius: 2em;
    width: 1.9em;
}
.ui-state-default, .ui-widget-content .ui-state-default {
    border: 1px solid #E10707;
    background: repeat-x scroll 50% 50% #f39b9b;
    font-weight: bold;
    color: #1C94C4;
    outline: medium none;
}
.ui-state-hover, .ui-widget-content, .ui-state-hover, .ui-state-focus, .ui-state-content, .ui-state-focus {
    border: 1px solid #125189;
    background-color:#78b7ef;    
}
.ui-slider .ui-slider-handle:hover{
    border: 1px solid #125189;
    background: repeat-x scroll 50% 50% #78b7ef;
}
.ui-slider-horizontal .ui-slider-range {
    top: -1px;
    height: 118%;
}
</style>
</apex:page>

 
  • March 12, 2015
  • Like
  • 0
Hello  Guys,
                 I  am having a trouble while running a JS on my button . I have a button name Make Available on my detail page and there is a pick list name status which is by-default Pending. Whenever user click on Make Available button then the status would automatically change from pending to Available. Following is my code :-
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var pro = new sforce.SObject('SPBE__Property__c'); 
pro.Id = '{!SPBE__Property__c.Id}'; 
pro.SPBE__Status__c= 'Available'; 
var result = sforce.connection.update([pro]); 
if(result[0].success=='true'){ 
    alert('The Status Updated Successfully'); 
} 
else{ 
    alert('The Status Updated Unsuccessfully'); 
} 
window.location.reload(true);
}


 
  • March 04, 2015
  • Like
  • 0
Hello All,
             I have a query regarding the Account .. I have a Customize Vf page  and i want th user that whenver the user edit the person account page then the business account page button should be disable.
Note:-Disable  should be only in the edit Mode  page .
Is there anybody who worked over it ?
  • February 24, 2015
  • Like
  • 0
Hello All,
            I came to a recent scenario where i have 10,000 existing leads in my lead object. I want to delete the existing duplicate leads which have duplicate emails in my lead object. So that the anonymous emails cant be sent . i have wrote a trigger but its not working. Help me out.
  • February 20, 2015
  • Like
  • 0
Hello All,
          While working on lightning App Builder I went to  some demo videos of lightning.Some differences i found in my org  in my lightning app builder in the drop-down menu(circle) select devices, Here i found only Phone and tablet but in the demo i saw laptop and smart-watch also. Why in my org its not visible ?


User-added image
  • February 16, 2015
  • Like
  • 0
Hi all,
          While working on my lightning components, one error is coming .  Is there anybody who can help me out ?
Error-  Cannot read property 'push' of undefined.
here is the sample of Helper.js


({
    createBAccount : function(component,BAccount) {
        this.upsertExpense(component, expense, function(a) {
            var BAccount = component.get("v.BAccount");
            BAccount.push(a.getReturnValue());
            component.set("v.BAccount", BAccount);
            this.updateTotal(component);
        });
    },
    upsertExpense : function(component, BAccount, callback) {
        var action = component.get("c.saveBAccount");
        action.setParams({
            "BAccount": BAccount
        });
        if (callback) {
            action.setCallback(this, callback);
        }
        $A.enqueueAction(action);
    },
})


The bold one is  getting an error over here .
  • February 16, 2015
  • Like
  • 0
I'm trying to create a custom OnClick JavaScript button that will update a Status field on my detail page  from Pending to Available when clicked on button. Here is my follwing code:-

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var pro = new sforce.SObject('APPa__Tickets__c'); 
pro.Id = '{!APPA__Tickets__c.Id}'; 
pro.APPA__Status__c = 'Available'; 
var result = sforce.connection.update([pro]); 
if(result[0].success=='true'){ 
alert('The Status Updated Successfully'); 
else{ 
alert('The Status Updated Unsuccessfully'); 

window.location.reload(true);}

But when i click on the button it shows an error:Unexpected Token else.  Help me out ..
  • February 13, 2015
  • Like
  • 0
I have made a controller of self user registration . and while doing this what i am trying to make is that when ever user registered a password link should be sent on user email id ,just like when ever we create a org and sales force send a email verification link on our email id. Is it possible to do so? If yes then How? Help me out Guys.!! Here is a Controller:-
 
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 String CompanyName { get; set; }
public String fPhone { get; set; }

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 = '00e90000001jxLE'; // To be filled in by customer.
     String roleEnum = 'Partner User'; // To be filled in by customer.
     String accountId = ''; // To be filled in by customer.
     String CityOffice='00590000003BnUR';
     String StateOffice='00590000003BnSa';
     String Owner='00590000003Bn3L';   // sytem Admin ID 
     String AccountNumber;
     Account account= new Account();
     account.Name =firstName;
     account.SPBE__First_Name__c= firstName;
     account.SPBE__Last_Name__c = lastName;        
     account.SPBE__Email__c=email;
     insert account;         

     account.OwnerId=Owner;
    // account.isPartner=true;

     update account;
     AccountNumber=account.Account_Number__c;
    accountId = account.Id;
    String userName = email;
    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.CommunityNickname = firstName+AccountNumber;
    u.CompanyName=CompanyName;
    u.Phone=fPhone;
    u.SPBE__City_Office__c=CityOffice;
    u.SPBE__State_Office__c=StateOffice;
    u.ProfileId = profileId;

    String userId = Site.createPortalUser(u, accountId, password); 

    if (userId != null) { 
        if (password != null && password.length() > 1) {
            return Site.login(userName, password, ApexPages.currentPage().getParameters().get('startURL'));
        }
        else {
            PageReference page = System.Page.CommunitiesSelfRegConfirm;
            page.setRedirect(true);
            return page;
        }
    }
    return null;
}





 
  • February 02, 2015
  • Like
  • 0
Hello all,
               A small attention to all the Sales force delegates. I have make an Web app with the community.

My query is that when the user self registered then the verification link send to the user email Address.

Through this link user can set his password and we will satisfied that the dummy users aborted while register into the community . is it possible ?
  • January 15, 2015
  • Like
  • 0
Hello ,
While i am running my site on Salesforce1 App then it is showing this Error:
 
You cannot view this page. either because you don't have permission salesforce or because the page is not supported on mobile devices salesforce.

I am not able to understand whats this ?  Help me out i am   at the end stage to launch mysite .
  • January 14, 2015
  • Like
  • 0
Hi Guys,
                  I know that Community Nickname  is  system generated fields and they automatically take values once user record is created. In case of Self registration user.

 I removed the Community Nickname from the Self registration  Community page and i  want to show the community nickname along with some number  automatically generated when user registered in community ? Is It possible?
  • January 12, 2015
  • Like
  • 0
Is it possible that if a user self registered in the community then the details would be stored in their separate ACCOUNT instead of self-registered users are all added to the same Account record. If Yes then how ?
  • January 09, 2015
  • Like
  • 0
I want to user the google map on my detail page layout. how can we use this like my section is Location having street address and City How can we use this on the custom object.
  • December 30, 2015
  • Like
  • 0
Hello All,
            I have written code in apex and visualforce  to saving the Geo location in my detail page. While doing this an error is coming on this particular line.It throw an error on my particular this code:
 
newSupply.GeoLocation__Latitude__s=decimal.valueOf(latitude);
newSupply.GeoLocation__Longitude__s=decimal.valueOf(longitude);
"Visualforce Error System.Type Exception: Invalid decimal".
 
  • March 30, 2015
  • Like
  • 0
Hello Guys  i am stuck in the google map while using it in VF page . I need to  locate the city along with the street adress on the google map and   draw radius when ever user click on  the search button . My Autocomplete textbox is working  . I need to add the seach functionality  on the seach button.
Here is my code:-
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
<script type="text/javascript">
        var map;
        
function initializeField() {
var input = document.getElementById('page:frm:field');           
var autocomplete = new google.maps.places.Autocomplete(input); 
var mapOptions = {
zoom:6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,

center: new google.maps.LatLng(20.593684,78.962880)
};
map = new google.maps.Map(document.getElementById('MyMap'),
  mapOptions);
}
google.maps.event.addDomListener(window, 'load', initializeField);

</script>


 <input type="button" class="btn customBtn pull-right"  value="Search" />

Help me out
  • March 25, 2015
  • Like
  • 0
Hello Guys,
                I have wrote a trigger on account object that  whenever a user enter duolicate  phone number or email then it will show an error on page and the info will not stored in the account object.
Here is the code
trigger AccountTrigger on Account (before insert, before update)
{
    //Account duplicate protection system.
    if (Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate))
    {
        Map<String, Account> anAccountMap = new Map<String, Account>();
        for (Account anAccount : System.Trigger.new)
        {
            // Make sure we don't treat an mobile phone that  
            // isn't changing during an update as a duplicate.  
            if ((anAccount.Phone != null) && (Trigger.isInsert || 
                      (anAccount.Phone != Trigger.oldMap.get(anAccount.Id).Phone)))
            {
                // Make sure another new Account isn't also a duplicate  
                if (anAccountMap.containsKey(anAccount.Phone))
                {
                    anAccount.Phone.addError('Another new Account has the same mobile phone.');
                    System.debug('*** Error: found account with dublicate mobile phone: ' + anAccount);
                } else
                {
                    anAccountMap.put(anAccount.Phone, anAccount);
                }
            }
        }  
        // Using a single database query, find all the Accounts in  
        // the database that have the same mobile phone as any  
        // of the Accounts being inserted or updated.  
        for (Account aDBAccount : [SELECT Phone FROM Account WHERE Phone IN :anAccountMap.KeySet()])
        {
            Account newAccount = anAccountMap.get(aDBAccount.Phone);
            newAccount.Phone.addError('An Account with this mobile phone already exists.');
            System.debug('*** Error: found account with dublicate mobile phone: ' + newAccount);
        }
    }
}
Note:-- The thing is that its working but  its not showing any erorr on my particular page. Any help from the MVP's or the consultant  will be great.
Thanx
 
  • March 23, 2015
  • Like
  • 0
Hello All please pay attention to this  I have a autocomplete vf page  in which the  one text box is there search account name. i want that whenever the user enter  the name  then the name should come along with his phone number.. right now  only number is coming /Below is the  VF  code and controller code
Vf page:- 
<apex:page controller="AutoCompleteController" >
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js" />
    <apex:styleSheet value="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/smoothness/jquery-ui.css" />
    
    <style>
        .displayNone { 
            display:none; 
        }
        .displayBlock {
            display:block;
        }
        .ui-autocomplete-loading { 
            background: white url(/img/loading32.gif) right center no-repeat;
            background-size:15px 15px; 
        }
        .placeHolder {
            font-style: italic;
        }
    </style>
    
    <apex:form id="autoCompleteForm" >
        
        <apex:pageBlock id="searchBlock" >
            <apex:pageBlockSection id="searchSection" title="Search Your Account" columns="1" >
                 <apex:outputLabel value="Account Name" for="AccountBox" />
                 <apex:outputPanel >
                     <apex:inputText id="AccountTextBox" value="{!searchTerm}" styleClass="placeHolder"/>
                     <apex:inputHidden id="searchAccountId" value="{!selectedAccount}" />
                 </apex:outputPanel>
            </apex:pageBlockSection>
        </apex:pageBlock>
        
    </apex:form>
    
    <script type="text/javascript">
        var PLACEHOLDER = 'Enter Account Name Here'; 
        var AccountObjects;
        var queryTerm;
        $('[id$=AccountTextBox]').autocomplete({
            minLength: 2,
            source: function(request, response) {
                        queryTerm = request.term;
                        AutoCompleteController.searchAccount(request.term, function(result, event){
                            if(event.type == 'exception') {
                                  alert(event.message);
                            } else {
                                 AccountObjects = result;
                                 response(AccountObjects );
                            }
                        });
                   },
            focus: function( event, ui ) {
                    $('[id$=AccountTextBox]').val( ui.item.Name );
                    return false;
                    },
            select: function( event, ui ) {
                        $('[id$=AccountTextBox]').val( ui.item.Name );
                        $('[id$=AccountTextBox]').val( ui.item.Phone);
                        $('[id$=searchAccountId]').val( ui.item.Id );
                        return false;
                    },
         })
         .data( "autocomplete" )._renderItem = function( ul, item ) {
            var entry = "<a>" + item.Name;
             var entry = "<a>" + item.Phone;
           
            entry = entry + "</a>";
            entry = entry.replace(queryTerm, "<b>" + queryTerm + "</b>");
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( entry )
                .appendTo( ul );
        };
            
        // Add or remove placeholder values
        $('[id$=AccountTextBox]').val(PLACEHOLDER);
        $('[id$=AccountTextBox]').on("focus",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === PLACEHOLDER ){
                $tgt.val('');
                $tgt.removeClass('placeHolder');
            }
        });
        $('[id$=AccountTextBox]').on( "blur",  function(event){
            $tgt = $(event.target);
            if($tgt.val() === '' ){
                $tgt.val(PLACEHOLDER);
                $tgt.addClass('placeHolder');
            }
        });
    </script>
</apex:page>
Controller:-
public with sharing class AutoCompleteController {
    
    // Instance fields
    public String searchTerm {get; set;}
    public String selectedAccount {get; set;}
    
    // Constructor
    public AutoCompleteController() {
        
    }
    
    // JS Remoting action called when searching for a account name
    @RemoteAction
    public static List<Account> searchAccount(String searchTerm) {
        System.debug('Account Name is: '+searchTerm );
        List<Account> Account= Database.query('Select Id, Name, Phone from Account where name like \'%' + String.escapeSingleQuotes(searchTerm) + '%\'');
        return Account;
    }
    
}
  • March 17, 2015
  • Like
  • 0
Hello All,
             I have a query regarding the Account .. I have a Customize Vf page  and i want th user that whenver the user edit the person account page then the business account page button should be disable.
Note:-Disable  should be only in the edit Mode  page .
Is there anybody who worked over it ?
  • February 24, 2015
  • Like
  • 0
Hello All,
            I came to a recent scenario where i have 10,000 existing leads in my lead object. I want to delete the existing duplicate leads which have duplicate emails in my lead object. So that the anonymous emails cant be sent . i have wrote a trigger but its not working. Help me out.
  • February 20, 2015
  • Like
  • 0
Hi all,
          While working on my lightning components, one error is coming .  Is there anybody who can help me out ?
Error-  Cannot read property 'push' of undefined.
here is the sample of Helper.js


({
    createBAccount : function(component,BAccount) {
        this.upsertExpense(component, expense, function(a) {
            var BAccount = component.get("v.BAccount");
            BAccount.push(a.getReturnValue());
            component.set("v.BAccount", BAccount);
            this.updateTotal(component);
        });
    },
    upsertExpense : function(component, BAccount, callback) {
        var action = component.get("c.saveBAccount");
        action.setParams({
            "BAccount": BAccount
        });
        if (callback) {
            action.setCallback(this, callback);
        }
        $A.enqueueAction(action);
    },
})


The bold one is  getting an error over here .
  • February 16, 2015
  • Like
  • 0
I'm trying to create a custom OnClick JavaScript button that will update a Status field on my detail page  from Pending to Available when clicked on button. Here is my follwing code:-

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var pro = new sforce.SObject('APPa__Tickets__c'); 
pro.Id = '{!APPA__Tickets__c.Id}'; 
pro.APPA__Status__c = 'Available'; 
var result = sforce.connection.update([pro]); 
if(result[0].success=='true'){ 
alert('The Status Updated Successfully'); 
else{ 
alert('The Status Updated Unsuccessfully'); 

window.location.reload(true);}

But when i click on the button it shows an error:Unexpected Token else.  Help me out ..
  • February 13, 2015
  • Like
  • 0
I have made a controller of self user registration . and while doing this what i am trying to make is that when ever user registered a password link should be sent on user email id ,just like when ever we create a org and sales force send a email verification link on our email id. Is it possible to do so? If yes then How? Help me out Guys.!! Here is a Controller:-
 
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 String CompanyName { get; set; }
public String fPhone { get; set; }

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 = '00e90000001jxLE'; // To be filled in by customer.
     String roleEnum = 'Partner User'; // To be filled in by customer.
     String accountId = ''; // To be filled in by customer.
     String CityOffice='00590000003BnUR';
     String StateOffice='00590000003BnSa';
     String Owner='00590000003Bn3L';   // sytem Admin ID 
     String AccountNumber;
     Account account= new Account();
     account.Name =firstName;
     account.SPBE__First_Name__c= firstName;
     account.SPBE__Last_Name__c = lastName;        
     account.SPBE__Email__c=email;
     insert account;         

     account.OwnerId=Owner;
    // account.isPartner=true;

     update account;
     AccountNumber=account.Account_Number__c;
    accountId = account.Id;
    String userName = email;
    User u = new User();
    u.Username = userName;
    u.Email = email;
    u.FirstName = firstName;
    u.LastName = lastName;
    u.CommunityNickname = firstName+AccountNumber;
    u.CompanyName=CompanyName;
    u.Phone=fPhone;
    u.SPBE__City_Office__c=CityOffice;
    u.SPBE__State_Office__c=StateOffice;
    u.ProfileId = profileId;

    String userId = Site.createPortalUser(u, accountId, password); 

    if (userId != null) { 
        if (password != null && password.length() > 1) {
            return Site.login(userName, password, ApexPages.currentPage().getParameters().get('startURL'));
        }
        else {
            PageReference page = System.Page.CommunitiesSelfRegConfirm;
            page.setRedirect(true);
            return page;
        }
    }
    return null;
}





 
  • February 02, 2015
  • Like
  • 0
Hello all,
               A small attention to all the Sales force delegates. I have make an Web app with the community.

My query is that when the user self registered then the verification link send to the user email Address.

Through this link user can set his password and we will satisfied that the dummy users aborted while register into the community . is it possible ?
  • January 15, 2015
  • Like
  • 0
I had link the community login page, forgot password page and self registration page in the community. Now, after the user login it should enter his detailed home page. Any help?
  • December 29, 2015
  • Like
  • 0
How can we use the Facebook Social Sign on with salesforce.
  • December 26, 2014
  • Like
  • 0