• Prithviraj_Chavan
  • NEWBIE
  • 125 Points
  • Member since 2015
  • Salesforce Developer
  • Considerate Systems


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 42
    Replies
 <aura:attribute name="ideas" type="Idea[]" />
<ui:inputSelect class=" slds-float--left" label="Sort : " aura:id="selection" change="{!c.onChangeFunction}">
                <ui:inputSelectOption text="Trending" label="Trending" value="true" />
                <ui:inputSelectOption text="Popular" label="Popular"/>
                <ui:inputSelectOption text="Recent" label="Recent"/>
            </ui:inputSelect>

 onChangeFunction : function(cmp,event){
      var selected = cmp.find("selection").get("v.value");
   //onsole.log(selected);    
        if(selected=='Recent')
        {
             console.log('hi');
           var action = cmp.get("c.getIdea1");
            action.setCallback(this,function(response){
                if (response.getState() === "SUCCESS"){
                    alert('sqsq');
                    cmp.set("{!v.ideas}",response.getReturnValue());
                }
            }
        ); 
        }
    }

  @AuraEnabled
    public static List<Idea> getIdea1(){
        List<Idea> i=[SELECT Id, Title, Body, CreatedDate FROM Idea order by CreatedDate desc];
        System.debug('hi'+i);
        return [SELECT Id, Title, Body, CreatedDate FROM Idea order by CreatedDate desc];
    }

This is my above code but sort is not happening?
Hello,
Apologies for this basic question. This is my first interaction with Salesforce in general and Visualforce coding in particular...
I'm using Javascript on Visualforce page.
I need to insert few data items (all are strings) as Task on a given account. I've already obtained the account ID and my Calback function received the relevant strings to insert (i.e. no trigger or query is required).
How do I insert this information as Task for this user using Javascript code?
Note (just in case this info is relevant) that this is a click-to-dial implementation which shows the Phone button on all type of screens where phone number exists therefore it is not bound to any specific controller. 
Let me know if you require any further information from my side.
Thank you for any support
Harel
I'm trying to create a validation rule that when a picklist item is selected instead of the default value "XYZ", the AcitivityDat field is required if left blank when trying to save a record. I tried to create the VR that would reequire me to add 2 more picklist values to make it work. So, if a user selects, Left Message, Left Voicemail, or Emailed, the ActivityDate must not be blank, the VR should prompt them to fill in the ActivityDate field.
 
AND(ISPICKVAL(Call_Status__c, "Left Message"),ISBLANK(ActivityDate))

this syntax only works if the user selects Left Message, but I have 2 other values for the Call_Status__c picklist field. The default value is XYZ when a record is created. However, if a user selects another value besides XYZ, and tries to save the record without entering a value in the ActivityDate field, the VR should prompt them to fill in the Acitivity Date.

Thank you in advance!
Can any give me community login and registration example with visualforce and apex.. I have checked many links but those are not working..Thanks in advance. please suggest best approach to create community with my own css.
Can any give me community login and registration example with visualforce and apex.. I have checked many links but those are not working..Thanks in advance.
@RemoteAction
    public static String registerUser(String newUser){ 
        
        SiteUser newSiteUser = (SiteUser)System.JSON.deserialize(newUser, SiteUser.class);
        String userName = newSiteUser.email;
        try {
            Account acc = new Account();
            acc = [ SELECT Id FROM Account WHERE name = 'Customer' LIMIT 1];
            User userObj = new User(username = newSiteUser.email, 
                                    firstname= newSiteUser.firstname,
                                    lastname = newSiteUser.lastname, 
                                    email = newSiteUser.email,
                                    communityNickname = newSiteUser.firstname + '_'+Math.random(),
                                    alias = string.valueof(newSiteUser.firstname.substring(0,1) + 
                                                           newSiteUser.lastname.substring(0,1) + Math.random()),emailencodingkey='UTF-8',
                                                           languagelocalekey='en_US', 
                                                           localesidkey='en_US', 
                                                           timezonesidkey='America/Los_Angeles', 
                                    profileid = '00e0O000001xjVJ');
            System.debug('userObj		::	'+userObj);
            System.debug('acc		::	'+acc);
            String userId = Site.createPortalUser(userObj, acc.Id, newSiteUser.password,false);
            System.debug('User Created Successfully userId	::	'+userId);
        } catch(Site.ExternalUserCreateException ex) {
            List<String> errors = ex.getDisplayMessages();
            for (String error : errors)  {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, error));
                System.debug('Error Occurred	::	'+error);
            }
        }
        return null;
    }

Hi, I am creating a community user from custome registration page.. but not getting user id when using createPortal method
I have created below formual

SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITU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UBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Address4__c,"ALLEY","AL"),"AMBLE","AMB"),"APPROACH","APPR"),"ALLEY","AL"),"ARCADE","ARC"),"ARTERIAL","ART"),"AVENUE","AV"),"BAY","BAY"),"BEND","BEND"),"BRAE","BRAE"),"BREAK","BRK"),"BOULEVARD","BVD"),"BOARDWALK","BWK"),"BOWL","BWL"),"BYPASS","BYP"),"CIRCLE","CCL"),"CIRCUS","CCS"),"CIRCUIT","CCT"),"CHASE","CHA"),"CLOSE","CL"),"CORNER","CNR"),"COMMON","COM"),"CONCOURSE","CON"),"CRESCENT","CR"),"CROSS","CROS"),"COURSE","CRSE"),"CREST","CRST"),"CRUISEWAY","CRY"),"COURTS","CT"),"COURT","CT"),"COVE","CV"),"DALE","DALE"),"DELL","DELL"),"DENE","DENE"),"DIVIDE","DIV"),"DOMAIN","DOM"),"DRIVE","DR"),"EAST","EAST"),"EDGE","EDG"),"ENTRANCE","ENT"),"ESPLANADE","ESP"),"EXTENSION","EXTN"),"FLATS","FLTS"),"FORD","FORD"),"FREEWAY","FWY"),"GATE","GATE"),"GARDENS","GDN"),"GARDEN","GDN"),"GLADE","GLA"),"GARDENS","GDN"),"GLEN","GLN"),"GULLY","GLY"),"GRANGE","GRA"),"GREEN","GRN"),"GROVE","GV"),"GATEWAY","GWY"),"HILL","HILL"),"HOLLOW","HLW"),"HEATH","HTH"),"HEIGHTS","HTS"),"HUB","HUB"),"HIGHWAY","HWY"),"ISLAND","ID"),"JUNCTION","JCT"),"LANE","LA"),"LINK","LNK"),"LOOP","LOOP"),"LOWER","LWR"),"LANEWAY","LWY"),"MALL","MALL"),"MEW","MEW"),"MEWS","MWS"),"NOOK","NOOK"),"NORTH","NTH"),"OUTLOOK","OUT"),"PATH","PATH"),"PARADE","PDE"),"POCKET","PKT"),"PARKWAY","PKW"),"PLACE","PL"),"PLAZA","PLZ"),"PROMENADE","PRM"),"PASS","PS"),"PASSAGE","PSG"),"POINT","PT"),"PURSUIT","PUR"),"PATHWAY","PWAY"),"QUADRANT","QD"),"QUAY","QU"),"REACH","RCH"),"ROAD","RD"),"RIDGE","RDG"),"RESERVE","REST"),"REST","REST”),"RETREAT","RET"),"RIDE","RIDE"),"RISE","RISE"),"ROUND","RND"),"ROW","ROW"),"RISING","RSG"),"RETURN","RTN"),"RUN","RUN"),"SLOPE","SLO"),"SQUARE","SQ"),"STREET","ST"),"SOUTH","STH"),"STRIP","STP"),"STEPS","STPS"),"SUBWAY","SUB"),"TERRACE","TCE"),"THROUGHWAY","THRU"),"TOR","TOR"),"TRACK","TRK"),"TRAIL","TRL"),"TURN","TURN"),"TOLLWAY","TWY"),"UPPER","UPR"),"VALLEY","VLY"),"VISTA","VST"),"VIEW","VW"),"VIEWS","VW"),"WAY","WAY"),"WOOD","WD"),"WEST","WEST"),"WALK","WK"),"WALKWAY","WKWY"),"WATERS","WTRS"),"WATERWAY","WRY"),"WYND","WYD")


Missing )   please let me help to fix issue

Hello,

I have a Lightning Component with an Apex controller. The controller has a constructor that sets some variables, but it doesn't seem to be running when I load my component because the variable is null when I call another function. I can't call it from the component either as I get a notification that "AuraEnabled does not apply to Constructors".
 

See below for an example of what I mean but my case is a lot more complex as I have quite a few variables that need to be set at the beginning and calling a SOQL query every time I call a function that needs these would not be efficient. 
 

public class MyController{

   public User currentUser;

   public MyController(){
      currentUser = [Select Id, FirstName from User where  Id =: UserInfo.getUserId();]
   }

    @AuraEnabled
   public static String getMyName(){
      return currentUser.FirstName;
   }

}
  • I have class A and I want to display List<A> on VF Page.
  • // Class A
    public with sharing class A
    {
        public String p;
        public String q;
        public String r;
        public String s;
        public String t;
    }
    
    // My Apex Code
    public class MyApexClass
    {
        public void m1()
        {
            StaticResource sr = [select id,body from StaticResource Where Name = 'MyFile'];
            String contents = sr.body.toString();
            List<A> list_obj = new List<A>();
            for(String line : contents.split('\n')) 
            {
                String[] myArray= line.split('#');
                A a = new A();
                a.p = myArray[0];
                a.q  = myArray[1];
                a.r  = myArray[2];
                a.s  = myArray[3];
                a.t  = myArray[4];
                list_obj.add(a) ;
            }
        }
    }

     

 
Hello every one.
  I m trying to call my VF pages in TabPanel. but i dont have idea how to call that pages in this below tab.

User-added image
This is my VF PAGE CODE
<apex:page controller="TabTest">
 <apex:tabPanel switchType="client" selectedTab="{!ActiveTab}" id="slipTabPanel">
    <apex:tab label="Tab 1" name="tab1" id="tab1">
      Tab1
    </apex:tab>
    <apex:tab label="abb" name="abb" id="abb">
      Tab2 
    </apex:tab>
    <apex:tab label="Tab 3" name="tab3" id="tab3">
      Tab3
    </apex:tab>
 </apex:tabPanel>
</apex:page>
And i want to call this page in Tab

User-added image

please guid me.
Thanks in advance

 
Hi All,

i am new in apex code i write a trigger and dont have idea about the handler class so i directly write logic in trigger itself. it would be great if anybody let me know how to write handler class and call this trigger code. 
trigger Lookupuserrecord on Account (before insert, before update) {
        
        Set<Id> ParentIds = New Set<Id>();
        For(Account Acc : Trigger.New)
    {
        ParentIds.Add(Acc.Master__c);
    }
       List<Master__c> ParentList = [Select Id,test_user1__c from Master__c where id =: ParentIds];
       
       For(Account CO : Trigger.New)
    {    
        For(Master__c PA : ParentList)
        {
            IF(CO.Master__c == PA.ID)
            {
                IF(PA.test_user1__c != NULL)
                {
                    CO.test_user1__c = PA.test_user1__c ;
                }
            }
        }
    }    
       
        
}

 
I am using this validation formula but it's not working

OR(LEN(URL__c) = 1,NOT(CONTAINS("www.",URL__c)))
public Class AvoidRecursion{
    private static boolean firstRun = true;
    public static boolean isFirstRun(){
    if(firstRun){
      firstRun = false;
      return true;
    }else{
        return firstRun;
    }
    }
}
 

trigger UpdateSelfManage on Case (after insert, after update) {


  if (AvoidRecursion.isFirstRun())

  {
     
    //Record Ids
    List<RecordType> rList = new List< RecordType>([SELECT Id, Name FROM RecordType WHERE SObjectType = 'Case' AND DeveloperName = 'Amend_Enrolment' ]);
    Id caId = !rList.isEmpty() ? rList[0].Id : null;

    
    //Unique set of Course Enrolments IDs to capture
    Set<ID> setofCEIds = new Set<ID>();

      
     for (Case c: Trigger.New){
       if ((c.RecordTypeId == caId) && (c.Origin == 'Student Portal') && (c.Subject == 'Self Managed Amendment') && (c.Status == 'Closed')) {
       setofCEIds.add(c.Course_Enrolment__c);
       }
     }
      
    
    //If the list has anything in it then loop through the list of Course Enrolments and then through the related cases for each CE. If any of the related cases has the conditions as
    //described below then update the self manage statud to 'Open' and add to the listofCEstoupdate list. When all of the looping through the list of CEs is done then bulk update the list
    //outside of the loop
  
      if (setofCEIds.size() > 0) {

      //Flag to test if the current CE needs to be updated or not
      Boolean updatethefield = true;

      //List of Course Enrolments to query which also pulls in info from the related case record
      List<Course_Enrolment__c> listofCEs = [SELECT Id, Self_Manage_Status__c, (SELECT Id, RecordTypeId, Origin, Subject, Status, Course_Enrolment__c FROM Cases__r) FROM Course_Enrolment__c WHERE Id in :setofCEIds];

      //New empty list of Course Enrolements to add to and then finally update
      List<Course_Enrolment__c> listofCEstoupdate = new List<Course_Enrolment__c>();


        for (Course_Enrolment__c ce : listofCEs){

          updatethefield = True;

          for (Case rc : ce.Cases__r){
          
            if ((rc.Status <> 'Closed') && (rc.Origin == 'Student Portal') && (rc.Subject == 'Self Managed Amendment') && (rc.RecordTypeId == caId)){

                updatethefield = False; 
            }
          }

          if (updatethefield == True){

              ce.Self_Manage_Status__c = 'Open';
              listofCEstoupdate.add(ce);
            }
        }

        Update listofCEstoupdate;

      }

    }

}

Dear All - Have been trying to resolve a recusion error and cannot deploy the above trigger to production. Any feedback is greatly appreciated!
Account is the parent of a custom object in our org (Relationship). I would like to get the parent record's ID and the child record's ID any time there is a new Relationship created. I am writing a trigger to perform some checks..like seeing if the relationship already exists. How would I get the record ID of the Account record and the Relationship record in an apex trigger? Thanks for your help in advance!
Once you complete a superbadge, you can no longer view the challenge list. Is there a list somewhere of all the superbadge challenges so I can go back and review them?
I have a vendor that wants to send new records to our existing RestResource via URL parameters (...abc.com?Name=Sample&Phone=8135551212).  How can I accept this?  I have been looking into JSON.deserializeuntyped(req.requestbody.tostring() but I just cant get anything to work. 
As a side note, my RestResource is exposed publicly via site.com with permissions to POST only.  
Here is a sample of what my code currently looks like.  


@RestResource(urlMapping='/abc/*')

global with sharing class sample {
    @HttpPost
    global static Map <String,String> createrecord (String Name,  
                                                    String Phone) {
      
        Map <String, String> s = new Map <String, String>();
        
        record r = new record(
            Name__c = Name,
            Phone__c = Phone);

        Database.SaveResult db = Database.insert(r, false);
        if(db.isSuccess()){
            s.put('isSuccess','True');
            s.put('status','Success');
            s.put ('RecordId',r.Id);
        }
        else{
            s.put('isSuccess','False');
            s.put('status','failure');
            s.put('message','Error');
            s.put('errorCode','Not Found');
            List <Database.Error> errors = db.getErrors();
            for(Database.Error error : errors){
                s.put('error', error.getMessage());
            }
        }
        return s;
    }
}
{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}
getDate = function(dte){
var day = dte.getDay() < 9 ? '0'+dte.getDay() : dte.getDay();
alert(day);
var month = dte.getMonth() < 9 ? '0'+dte.getMonth() : dte.getMonth();
alert(month);
alert(month+'/'+day+'/'+dte.getFullYear());
return month+'/'+day+'/'+dte.getFullYear();


}
 

 
var Vendor= new sforce.SObject('Vendor__c');
 
Vendor.Name = '{!Interview__c.First_Name__c} {!Interview__c.Last_Name__c}';
Vendor.Primary_Contact__c = '{!Interview__c.First_Name__c} - {!Interview__c.Last_Name__c}';
Vendor.Primary_Contact_Phone__c = '{!Interview__c.Phone_Number__c}';
Vendor.Phone__c = '{!Interview__c.Phone_Number__c}';
Vendor.Primary_Contact_Email__c = '{!Interview__c.Email__c}';
Vendor.Address__c = '{!Interview__c.Home_Address__c}';
Vendor.Emergency_Contact_Name__c = '{!Interview__c.Emergency_Contact_Name__c}';
Vendor.Emergency_Contact_Number__c     = '{!Interview__c.Emergency_Contact_Number__c}';
Vendor.Emergency_Contact_Relationship__c = '{!Interview__c.Emergency_Contact_Relation__c}';
Vendor.SS_or_Tax_ID__c = '{!Interview__c.Tax_ID__c}';
Vendor.Labor_Company__c = true;

var dte='{!Interview__c.Birthday_plus_1__c}';

var dat =new Date(dte).toISOString();

 
Vendor.DOB__c = dat;

Vendor.recordtypeid ='012G0000001YaqwIAC';


result = sforce.connection.create([Vendor]);

var c = new sforce.SObject("Interview__c");
c.id = "{!Interview__c.Id}";
c.Application_Status__c = 'Hired';
c.Vendor__c=result[0].id;
result1 = sforce.connection.update([c]);
document.location.reload(true)


 
if(result[0].success == 'true'){
    alert('An New Vendor with Name - ' + Vendor.Name + ' was Created Successfully.');
}
I want to get difference of num of days between createddate and current date weather i should use now or today function
Hi, I have written helper class for updating opportunity. if Event Status = 'Cancelled' then I am updating opportunity Stage Field else if Event Type = 'Consultation'.  then I updating Opportunity Date field. I am trying to update both logic if both matching matched.

This the class I have written.
  1. public class EventHandler{
  2.     
  3.     public static void OpportunityStageUpdateBaseOnEventStatus (List<Event> evnList){
  4.         Boolean condition1=false;
  5.         Boolean condition2=false;
  6.         Map<Id,Event> mapID = new Map<Id,Event>();
  7.         Set<Opportunity> OppSet = new Set<Opportunity>();
  8.         for(Event evn: evnList){
  9.             mapID.put(evn.Id,evn);
  10.         }
  11.         System.debug('mapID'+mapID);
  12.         for(Event evn: mapID.values()){
  13.             if(evn.Type__c == 'Consultation'){
  14.                 System.debug('1');
  15.                 condition1=true;
  16.                 Opportunity opp = new Opportunity();
  17.                 opp.Id = evn.WhatId;
  18.                 Opp.Demo_Date_Time__c = evn.StartDateTime;
  19.                 OppSet.add(opp);                
  20.             }else if(evn.Status__c == 'cancelled'){
  21.                 System.debug('2');
  22.                 condition2=true;
  23.                 Opportunity opp = new Opportunity();
  24.                 opp.Id = evn.WhatId;
  25.                 Opp.StageName = 'Closed Lost';
  26.                 OppSet.add(opp);
  27.             }else if(condition1 ==true && condition2 ==true){
  28.                 System.debug('3');
  29.                 Opportunity opp = new Opportunity();
  30.                 opp.Id = evn.WhatId;
  31.                 Opp.Demo_Date_Time__c = evn.StartDateTime;
  32.                 Opp.StageName = 'Closed Lost';
  33.                 OppSet.add(opp);
  34.             }         
  35.         }
  36.         
  37.         if(OppSet.Size()>0){
  38.             System.debug('SIZE >>'+OppSet.Size());
  39.             update new List<Opportunity>(OppSet);
  40.             System.debug('SIZE >>'+OppSet);
  41.         }
  42.         
  43.                 
  44.     }
  45.     
  46. }