• madhan bondalapati
  • NEWBIE
  • 19 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 12
    Questions
  • 10
    Replies
I want to open an lightning page when we click on the button on Opportunity layout.

One way is create a VF page and embedded the lightning component in it.Is there any other way we can acheive this 
Hi all
I have a custom button on the page layout , when users clicks it will call vf page ,where i am doing form post on the page load with Json format.
My code as follows.

<apex:page standardController="Opportunity">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
       <form enctype='application/jsonp' id="frm" action="https://w7-d2rljpn1:8084/CTRWeb/Index.jsp" method="POST" > 
           <input type="hidden" name ="information"  value="" id="accId"/>
       </form>
       <script>    
      // send ajax
               alert('neter here');
               window.onload= function ajax(){
                alert('enter here1');
                var payLoad={'AccountId':'{!Opportunity.Account.Id}','Opportunityid':'{!Opportunity.id}','cisId':'{!Opportunity.Account.Client_ID__c}','advicentId':'{!Opportunity.Account.AdvicentId__c}','advicentPlanIdFF':'{!Opportunity.AdvicentPlanIdFF__c}','advicentPlanIdAA':'{!Opportunity.advicentPlanIdAA__c}','engagementId':'{!Opportunity.engagementId__c}','prefix':'{!Opportunity.Account.Salutation}','firstName':'{!Opportunity.Account.FirstName}','middleName':'{!Opportunity.Account.Middle_Initial__c}','lastName':'{!Opportunity.Account.LastName}','suffix':'{!Opportunity.Account.Suffix__c}'};
                alert('enter here2');
                
                var jsonRequest = JSON.stringify(payLoad);
                document.getElementById('accId').value = jsonRequest;
                console.log(jsonRequest);
                $.ajax({
                    url:'https://w7-d2rljpn1:8084/CTRWeb/Index.jsp', // url where to submit the request
                    type : "POST", // type of action POST || GET
                    dataType : "jsonp", // data type
                    data : jsonRequest , // post data || get data
                    headers: {'Content-Type' : 'application/json',
                               'Accept': 'application/json'},
                    success : function(data) {
                        // you can see the result from the console
                        // tab of the developer tools
                        console.log(result);
                    },
                    error: function(xhr, resp, text) {
                        console.log('ajax loading error...');

                    }
                });
                document.getElementById("frm").submit();
        }
    
    </script>    
</apex:page>


I am seeing the Console as json format. but at the receiving end they are seeing data with Ascii values .I am not able to find out what the issue was.And let me know how to redirect the user to different screen.after posting data was sucess full

 
Hi Folks

I have Standard object where it had Custom button, when clicking that button we have to do form post  using Json body not with HTML. Could you please letme know how will be the approach and sample code
I am CSV file which contains more than 10k records, i have button on the Vf page where it takes csv file and insert into the Salesforce .but will throw error when the count is more than 1000, .So that the reason i went to batch job.Let me know how to pass the CSv data to batch job,and process and insert in to the salesforce.

Below is the Code for records Lessthan 1000 records.Please share if you have code sample for Batch

Visaul force:

<apex:page controller="ExcelData" >
    <apex:form >
        <apex:pageMessages />
            <apex:pageBlock >
                <apex:pageBlockSection columns="3">
                    <apex:inputFile fileName="{!csvAsString}" value="{!csvFileBody}"></apex:inputFile>
                        <apex:commandButton value="ImportAccounData" action="{!ImportCSVFile}"/>               
                </apex:pageBlockSection>         
            </apex:pageBlock>  
         <apex:pageBlock >
             <apex:pageblockTable value="{!AccList}" var="acc">
                 <apex:column value="{!acc.Name}" />
                 <apex:column value="{!acc.AccountNumber}"/>
                 <apex:column value="{!acc.Type}"/>
                 <apex:column value="{!acc.Accountsource}"/>
                 <apex:column value="{!acc.Industry }"/> 

             </apex:pageblockTable>       
         </apex:pageBlock>
    
    </apex:form>


Controller: 

public with sharing class ExcelData {
    public String csvAsString { get; set; }
    public Blob csvFileBody { get; set; }
    Public List<Account>AccList{get;set;}
    Public List<String>CsvLines{get;set;}

public ExcelData(){
    CsvLines=new List<String>();
    AccList=new List<Account>();
}
Public void ImportCSVFile(){
    try{
    csvAsString=csvFileBody.toString();
    CsvLines=csvAsString.split('\n');
    
  for(integer i=1;i<CsvLines.size();i++){
      Account acc=new Account();
      List<String> CsvData=CsvLines[i].split(',');
      acc.Name=CsvData[0];
      acc.AccountNumber=CsvData[1];
      acc.Type=CsvData[2];
      acc.Accountsource=CsvData[3];
      acc.Industry=CsvData[4];
       Acclist.add(acc);
  }  
  insert Acclist;
}
  catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }
}
}
</apex:page>
Hi Following is code could you please help me what to change in my code to behave same in Crome and IE11

<aura:component implements="forceCommunity:availableForAllPageTypes">
    
    <div class="footer" id="footer" style="clear:both;">
        <table width="1000px" height="100%" align="center" class="footer_table" border="0">
            <tr>
                <td width="20px" class="top_align">&nbsp;</td>
                <td width="240px" class="top_align">
                    <ul class="list_style">
                        <li class="list_title"><a href="http://www8.hp.com/us/en/hp-information/index.html">About HP</a></li>
                        <li><a href="http://www8.hp.com/us/en/hp-news/newsroom.html">Newsroom</a></li>
                        <li><a href="http://h30261.www3.hp.com/">Investor relations</a></li>
                        <li><a href="http://www.hp.com/hpinfo/globalcitizenship/">Living Progress</a></li>
                        <li><a href="http://www8.hp.com/us/en/hp-information/accessibility-aging/index.html">Accessibility</a></li>
                        <li><a href="http://www8.hp.com/us/en/jobsathp/index.html">Jobs</a></li>
                    </ul>
                </td>
                <td width="260px" class="top_align">
                    <ul class="list_style">
                        <li class="list_title">Social Media</li>
                        <li><a href="http://h30611.www3.hp.com/t5/HP-Marketing-Optimization-Forum/bd-p/HPMarketingOptimizationForum">HP Software User Community</a></li>
                        <li><a href="http://h30611.www3.hp.com/t5/HP-Exstream-Forum/bd-p/HPExstreamForum">HP Exstream Technical Forum</a></li>
                        <li><a href="http://h20435.www2.hp.com/t5/HP-Software/bg-p/hpsoftware#.VrtU8fkrKUk">HP Software Blog</a></li>
                        <ul class="ul_media_links">
                            <li>
                                <a href="http://pages.exstream.hp.com/Redirect.aspx?EQ=38dfbe491fab00ead23516ac040433a64e9619b87ce173e4248f07fa2085d48099cdc3c051082603b1449dc361d3a9353915c107794f4a996be9572f39c08a99f07338113fb9142a7181072c061fa07e054b4cf67d8427e55849323c63f480a687c94c460d73d7116a8bf5f6d5d905b48726fa3c4b9d45e9af46e52c2934a61bbae44c052221cf49caeec01685faa82b20418afde05459b138d193bddee707723a1c1b9fd0e2963a1d9aefca2cb8904a"><img class="hf_blank" src="/hpcommunity/resource/Icons/facebook.jpg" /></a><!--/resource/Icons/facebook.jpg-->
                                <a href="http://pages.exstream.hp.com/Redirect.aspx?EQ=38dfbe491fab00ead23516ac040433a64e9619b87ce173e4248f07fa2085d48099cdc3c051082603b1449dc361d3a9353915c107794f4a996be9572f39c08a99f07338113fb9142a7181072c061fa07e054b4cf67d8427e55849323c63f480a687c94c460d73d7116a8bf5f6d5d905b48726fa3c4b9d45e9af46e52c2934a61b5928f8ba0e04f14bdd80583d8193d9933c33d416c03d5172878a14ba86e92d2c2e86981c50518a2416f334b7b929709a5b9e04c8365607656b5f185daf6c2739dbef1e126b45df8d"><img class="hf_blank" src="/hpcommunity/resource/Icons/linkedin.jpg" /></a><!--src="{!URLFOR($Resource.Icons, 'linkedin.jpg')}"-->
                                <a href="http://pages.exstream.hp.com/Redirect.aspx?EQ=38dfbe491fab00ead23516ac040433a64e9619b87ce173e4248f07fa2085d48099cdc3c051082603b1449dc361d3a9353915c107794f4a996be9572f39c08a99f07338113fb9142a7181072c061fa07e054b4cf67d8427e55849323c63f480a687c94c460d73d7116a8bf5f6d5d905b48726fa3c4b9d45e9af46e52c2934a61bb813b4c65d02646b62353f7259bc4afdcfc75d880f5d6ec461bc7e3c117deeb5a8c30e3dc34406ac0c97072eb06afc65"><img class="hf_blank" src="/hpcommunity/resource/Icons/twitter.jpg" /></a><!--src="{!URLFOR($Resource.Icons, 'twitter.jpg')}"-->
                            </li>
                        </ul>
                    </ul>
                </td>
                <td width="260px" class="top_align">
                    <ul class="list_style">
                        <li class="list_title"><a href="http://www8.hp.com/us/en/solutions/partner-programs/partners.html">HP Partners</a></li>
                        <li><a href="http://www8.hp.com/us/en/solutions/partner-programs/partners.html">HP Partner Programs</a></li>
                        <li><a href="https://h20375.www2.hp.com/portal/site/publicpartner-portal/">Become a partner</a></li>
                        <li><a href="http://www8.hp.com/us/en/store-finder/index.do">Find a reseller</a></li>
                        <li><a href="http://www8.hp.com/us/en/hp-information/partnerone-program/overview.html">PartnerOne</a></li>
                    </ul>
                </td>
                <td width="240px" class="top_align">
                    <ul class="list_style">
                        <li class="list_title">HP Software</li>
                        <li><a href="http://www.hpengage.com/">HP Engage</a></li>
                        <li><a href="http://www.hpengage.com/services/customer-support">HP Software Customer Care</a></li>
                        <li><a href="http://pages.exstream.hp.com/HPCustomerCare/">HP Exstream Customer Care</a></li>
                    </ul>
                </td>
                <td width="20px" class="top_align">&nbsp;</td>
            </tr>
            <tr>
                <td width="1000px" colspan="6">
                    <hr/>
                    <ul class="privacy_links">
                        <li><a href="http://customercare.hpengage.com/">Home</a><span class="hf_separ">|</span></li>
                        <li><a href="http://www8.hp.com/us/en/privacy/privacy.html">Privacy</a><span class="hf_separ">|</span></li>
                        <li><a href="http://www8.hp.com/us/en/privacy/privacy.html#hpdct">Cookies &amp; ad choices</a><span class="hf_separ">|</span></li>
                        <li><a href="http://www8.hp.com/us/en/privacy/terms-of-use.html">Terms of use</a><span class="hf_separ">|</span></li>
                        <li><a href="http://www8.hp.com/us/en/hp-information/recalls.html">Recalls</a></li>
                    </ul>
                    <div>
                        <p class="copyright">&copy; 2016 Hewlett-Packard Inc.</p>
                    </div>
                </td>                       
            </tr>
        </table>
    </div>
</aura:component>Crome behavingIE 11 behaving
Hi All i want to select a radio one at time ,but in my case i am selecting all radio buttons.Could you please help me in this issue.

I want to the save the selected values in the custom object .Here is my code for Visual force page and controller

Visualforce page :

<apex:page showHeader="false" sidebar="false" controller="SurveyContact">
<apex:pageMessages />
    <div align="center">
        <h1> Survey For Contact </h1>
    </div>
    <apex:form >
        <apex:pageBlock title="Survey Questions">
        <apex:outputPanel rendered="{!FirstScreen}">
            <apex:actionRegion >
                You will be answering a bunch of questions to plan your Long weekend in a Relaxing way. <br/>

                Click Start button below to get to your first question. <br/><br/>

                <apex:commandButton value="Start" action="{!StartSurvey}"/>
            </apex:actionRegion>
        </apex:outputPanel>
        <apex:outputPanel rendered="{!FirstQuestion}">
           <apex:actionRegion >     
            <table>       
                 <tr>
                    <td>
                        <apex:outputLabel value="Fun places to visit "/>
                    </td>
                    <td>
                        <apex:selectRadio value="{!PlaceToVisit}"/> 
                    </td>
                    <td>
                        Grand prismatic spring
                    </td>
                    <td>
                        <apex:selectRadio value="{!PlaceToVisit}"/> 
                    </td>
                     <td>
                        Grand Canyon of Yellowstone
                    </td>
                    <td>
                        <apex:selectRadio value="{!PlaceToVisit}"/> 
                    </td>
                    <td>
                       Hayden Valley
                    </td>
                    <td>
                        <apex:selectradio value="{!PlaceToVisit}"/>
                    </td>
                    <td>
                       Mammoth Springs
                    </td>                   
                    <td>
                        <apex:selectradio value="{!PlaceToVisit}"/> 
                    </td>
                    <td>
                    Norris Geyser Basin
                    </td>
                </tr>
            </table>
            <apex:commandButton value="Next" action="{!next}"/>
            
            </apex:actionRegion> 
        </apex:outputPanel>
        </apex:pageBlock>
            <!--<div align="center" draggable="false" >
                <apex:commandButton action="{!save}" value="Save"/>&nbsp;
                <apex:commandButton value="Next"/>
            </div>-->
    </apex:form>
</apex:page>

Controller:

public with sharing class SurveyContact {

  

    public String SurveySatisfaction {get;set;}
    public String PlaceToVisit {get;set;}
    public boolean FirstQuestion {get;set;}
    public boolean SecondQuestion {get;set;}
    public boolean FirstScreen {get;set;} {FirstScreen = true;}

    public PageReference save(){
    PageReference pr =new PageReference('a0W/e');
        return pr;
    }

    public void StartSurvey(){
        FirstQuestion = true;
        FirstScreen = false;
    }
      public void  next() {
       FirstQuestion=False;
       SecondQuestion=True;    
    }
    
}

 
Integration with marketing cloud how we can acheive ?
Hi All 

Could you please suggest interview questions for Marketing Cloud?
i am inserting 100 records inthat 50 insert,50 update through workbench.what will be the size of the trigger.new() .Whether it will 50 or 100?
 
Hi i am also trying to create a User with VF page,Everything work fine but i am not able to rerender the profile  picklist values based on the License pickl ist .Could you please any one help me out..And at last i have to send an email to the User by email notification,for that what i have to do 

My VF code:
<apex:page standardController="User" extensions="CreateUser">
    <apex:form >
        <apex:pageBlock mode="edit">
             <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!Save}"/>
                 <apex:commandButton value="Cancel" action="{!Cancel}"/>                           
             </apex:pageBlockButtons>
        
            <apex:pageBlockSection title="UserInformation" collapsible="False" columns="2">
            
                <apex:inputField value="{!User.IsActive}"/>
                <apex:inputField value="{!User.FirstName}"/>
                <apex:inputField value="{!User.LastName}"/>
                <apex:inputField value="{!User.UserName}"/>
                <apex:inputField value="{!User.Alias}"/>
                <apex:inputField value="{!User.Email}"/>
                <apex:inputField value="{!User.UserRoleID}"/>
                 <apex:inputField value="{!User.CommunityNickname}"/>
                <!--<apex:inputField value="{!User.userType}"/-->       
            </apex:pageBlockSection>
        
           <apex:pageBlockSection >
           
                <apex:inputField value="{!User.Phone}"/>
                <apex:inputField value="{!User.Extension}"/>
                <apex:inputField value="{!User.Fax}"/>
                <apex:inputField value="{!User.EmployeeNumber}"/>
                <apex:inputField value="{!User.FederationIdentifier}"/>
                <apex:inputField value="{!User.Division}"/>
                <apex:inputField value="{!User.Department}"/>                   
           
           </apex:pageBlockSection>
           
            <apex:pageBlockSection title="Liscence Information" collapsible="True" columns="2" >
                <apex:pageBlockSectionItem >

          <apex:outputLabel value="License" for="lic"></apex:outputLabel>

              <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                 <apex:selectOptions value="{!license}"/>
                    <apex:actionSupport event="onchange" rerender="selectedProfileId"/>
           </apex:selectList>

           </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                      <apex:selectList value="{!User.ProfileId}" multiselect="false" size="1" id="selectedProfileId">
                       <apex:selectOptions value="{!profile}" />
                           </apex:selectList>

                         </apex:pageBlockSectionItem>

            </apex:pageBlockSection>
             
             <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">

                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/>
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>

               </apex:pageBlockSection>

                     </apex:pageBlock>
    
    
    
    </apex:form>>
  
</apex:page>

<apex:page standardController="User" extensions="CreateUser">
    <apex:form >
        <apex:pageBlock mode="edit">
             <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!Save}"/>
                 <apex:commandButton value="Cancel" action="{!Cancel}"/>                           
             </apex:pageBlockButtons>
        
            <apex:pageBlockSection title="UserInformation" collapsible="False" columns="2">
            
                <apex:inputField value="{!User.IsActive}"/>
                <apex:inputField value="{!User.FirstName}"/>
                <apex:inputField value="{!User.LastName}"/>
                <apex:inputField value="{!User.UserName}"/>
                <apex:inputField value="{!User.Alias}"/>
                <apex:inputField value="{!User.Email}"/>
                <apex:inputField value="{!User.UserRoleID}"/>
                 <apex:inputField value="{!User.CommunityNickname}"/>
                <!--<apex:inputField value="{!User.userType}"/-->       
            </apex:pageBlockSection>
        
           <apex:pageBlockSection >
           
                <apex:inputField value="{!User.Phone}"/>
                <apex:inputField value="{!User.Extension}"/>
                <apex:inputField value="{!User.Fax}"/>
                <apex:inputField value="{!User.EmployeeNumber}"/>
                <apex:inputField value="{!User.FederationIdentifier}"/>
                <apex:inputField value="{!User.Division}"/>
                <apex:inputField value="{!User.Department}"/>                   
           
           </apex:pageBlockSection>
           
            <apex:pageBlockSection title="Liscence Information" collapsible="True" columns="2" >
                <apex:pageBlockSectionItem >

          <apex:outputLabel value="License" for="lic"></apex:outputLabel>

              <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                 <apex:selectOptions value="{!license}"/>
                    <apex:actionSupport event="onchange" rerender="selectedProfileId"/>
           </apex:selectList>

           </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                      <apex:selectList value="{!User.ProfileId}" multiselect="false" size="1" id="selectedProfileId">
                       <apex:selectOptions value="{!profile}" />
                           </apex:selectList>

                         </apex:pageBlockSectionItem>

            </apex:pageBlockSection>
             
             <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">

                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/>
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>

               </apex:pageBlockSection>

                     </apex:pageBlock>
      
    </apex:form>
  
</apex:page>




My controller:
public class CreateUser{
    private final User user;
    public createuser(Apexpages.standardcontroller cont){
    this.user=(user)cont.getrecord(); 
    //user.UserType=[select id ,name from UserLicense where name = 'Chatter Free'].name; 
    //user.ProfileId=[select id from Profile where name='Chatter Free User'].id;  
    }
    
    Public list<selectOption> getLicense(){
        List<selectOption> options=new List<selectoption>();
        options.add(new selectOption('', '- None -')); //for default values
        for(UserLicense u:[Select id,Name from UserLicense]){
            options.add(new selectoption(u.id,u.name));      
        
        }
        
        return options; 
    
    
    }    
    public List<selectOption> getProfile() {

      List<selectOption> options1 = new List<selectOption>(); //new list for holding all of the picklist options

      options1.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below

   
   for (Profile users1 :[SELECT Id,Name FROM Profile] )  {   

              options1.add(new selectOption(users1.Id, users1.Name)); //for all records found - add them to the picklist options

      }
    
    return options1;
    }
    }
I have one feild on opportunity ,it is checked the record should not be edited.I
wrote trigger like this ,but it is showing some error.Could anyone help in this

trigger DisableEdit on Opportunity (before update)
{
   Set<Id> parentIds=new Set<Id>();
   for(Opportunity opp : Trigger.old)
   {
            parentIds.add(opp.Id);
   }   
    Map<Id, Opportunity> parentMap=new Map<Id, Opportunity>();
   parentMap.putAll([Select Id from Opportunity where Oppty_Status__c = 'Closed' and Id in :parentIds]);
     for(Opportunity opp : Trigger.old)
    {
            if (parentMap.get(opp.Id)!= null)
      {
               opp.addError('You don\'t have Previlege to Edit a Renewal after status is set to Closed');
               
      }

    }           
}

It is showing error message at the opp.adderror.When i checked the debug log it is not passing that line
I wrote trigger like this ,but it is showing some error.Could anyone help in this

trigger DisableEdit on Opportunity (before update)
{
   Set<Id> parentIds=new Set<Id>();
   for(Opportunity opp : Trigger.old)
   {
            parentIds.add(opp.Id);
   }   
    Map<Id, Opportunity> parentMap=new Map<Id, Opportunity>();
   parentMap.putAll([Select Id from Opportunity where Oppty_Status__c = 'Closed' and Id in :parentIds]);
     for(Opportunity opp : Trigger.old)
    {
            if (parentMap.get(opp.Id)!= null)
      {
               opp.addError('You don\'t have Previlege to Edit a Renewal after status is set to Closed');
               
      }

    }           
}

It is showing error message at the opp.adderror.When i checked the debug log it is not passing that line
Hi, 

We're looking for an experienced Salesforce developer for work within our marketing and service technologies department. We are a major dutch retail company working globally.

We expect you to be able to work minimal of 20 hours a week. Have a great understanding of APEX and Visualforce and have a proven trackrecord. 

Send your resume to jhendriks@suitsupply.com or send me a message on the forum.

Thank you in advance for your message. 

Regards, 


 

 
Hi I'm new to Salesforce
In the follwing code, how can I avoid using the con List.
Is there a way in which you can use SOQL query on trigger.new directly instead of bringing in another List ??
trigger ContactTest on Contact (before insert, before update) {

    List<Contact> con = [Select Id, Account.Phone from Contact where Id in : trigger.new];
    for(Contact c: trigger.new)
    {

         for(Integer i=0; i< trigger.new.size() ; i++)
    {
        c.OtherPhone = con[i].Account.Phone;
    }
}

}

Also, can the above update be done with WOrkflow Rules ??

Thanks,
Murthy
Hello, 

I'm getting the error message "Challenge Not yet complete... here's what's wrong: 
The 'High Value Opportunities' report was not an Opportunities report type

I selected "Opportunities" for the report type so I'm not sure why this error is coming up. Any ideas?
Hi All 

Could you please suggest interview questions for Marketing Cloud?
i am inserting 100 records inthat 50 insert,50 update through workbench.what will be the size of the trigger.new() .Whether it will 50 or 100?
 
Hello!

Please, could you help me to edit the following class so I can use it to compare old and new values when using it in an After Update trigger? It is working as expected for an After Insert trigger, but I would need it to compare old and new values so only the records whose fields changes are updated. I understand I need to use Map instead of Set but I cannot see how for the User object.

Trigger:
trigger AllUserTriggers on User (after insert, after update) {
    if(Trigger.isAfter && Trigger.isInsert) {
            AllUserTriggersHandler.handleAfterInsert(Trigger.newMap.keySet());
    }
    if(Trigger.isAfter && Trigger.isUpdate) {
            AllUserTriggersHandler.handleAfterUpdate(Trigger.newMap.keySet());
    }
}

Class:
public class AllUserTriggersHandler {
    @future
    public static void handleAfterUpdate(Set<Id> UserIds) { 
        List <Contact> contactsToUpdate = new List <Contact>();
        List<User> userList = [SELECT Id, ContactId, Profile.Name, Username, IsActive FROM User WHERE Id IN :UserIds];
        for (User currentUser : userList) {
            if (currentUser.ContactId != null){
        		Contact con = new Contact();
                con.Id = currentUser.ContactId;
                con.User_profile__c = currentUser.Profile.Name;
                con.User_username__c = currentUser.Username;
                con.Active_User__c = currentUser.IsActive;
                contactsToUpdate.add(con);
            }
        }
        update contactsToUpdate;
    }
}
Thank you very much!
Jesus
Hi i am also trying to create a User with VF page,Everything work fine but i am not able to rerender the profile  picklist values based on the License pickl ist .Could you please any one help me out..And at last i have to send an email to the User by email notification,for that what i have to do 

My VF code:
<apex:page standardController="User" extensions="CreateUser">
    <apex:form >
        <apex:pageBlock mode="edit">
             <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!Save}"/>
                 <apex:commandButton value="Cancel" action="{!Cancel}"/>                           
             </apex:pageBlockButtons>
        
            <apex:pageBlockSection title="UserInformation" collapsible="False" columns="2">
            
                <apex:inputField value="{!User.IsActive}"/>
                <apex:inputField value="{!User.FirstName}"/>
                <apex:inputField value="{!User.LastName}"/>
                <apex:inputField value="{!User.UserName}"/>
                <apex:inputField value="{!User.Alias}"/>
                <apex:inputField value="{!User.Email}"/>
                <apex:inputField value="{!User.UserRoleID}"/>
                 <apex:inputField value="{!User.CommunityNickname}"/>
                <!--<apex:inputField value="{!User.userType}"/-->       
            </apex:pageBlockSection>
        
           <apex:pageBlockSection >
           
                <apex:inputField value="{!User.Phone}"/>
                <apex:inputField value="{!User.Extension}"/>
                <apex:inputField value="{!User.Fax}"/>
                <apex:inputField value="{!User.EmployeeNumber}"/>
                <apex:inputField value="{!User.FederationIdentifier}"/>
                <apex:inputField value="{!User.Division}"/>
                <apex:inputField value="{!User.Department}"/>                   
           
           </apex:pageBlockSection>
           
            <apex:pageBlockSection title="Liscence Information" collapsible="True" columns="2" >
                <apex:pageBlockSectionItem >

          <apex:outputLabel value="License" for="lic"></apex:outputLabel>

              <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                 <apex:selectOptions value="{!license}"/>
                    <apex:actionSupport event="onchange" rerender="selectedProfileId"/>
           </apex:selectList>

           </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                      <apex:selectList value="{!User.ProfileId}" multiselect="false" size="1" id="selectedProfileId">
                       <apex:selectOptions value="{!profile}" />
                           </apex:selectList>

                         </apex:pageBlockSectionItem>

            </apex:pageBlockSection>
             
             <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">

                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/>
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>

               </apex:pageBlockSection>

                     </apex:pageBlock>
    
    
    
    </apex:form>>
  
</apex:page>

<apex:page standardController="User" extensions="CreateUser">
    <apex:form >
        <apex:pageBlock mode="edit">
             <apex:pageBlockButtons >
                 <apex:commandButton value="Save" action="{!Save}"/>
                 <apex:commandButton value="Cancel" action="{!Cancel}"/>                           
             </apex:pageBlockButtons>
        
            <apex:pageBlockSection title="UserInformation" collapsible="False" columns="2">
            
                <apex:inputField value="{!User.IsActive}"/>
                <apex:inputField value="{!User.FirstName}"/>
                <apex:inputField value="{!User.LastName}"/>
                <apex:inputField value="{!User.UserName}"/>
                <apex:inputField value="{!User.Alias}"/>
                <apex:inputField value="{!User.Email}"/>
                <apex:inputField value="{!User.UserRoleID}"/>
                 <apex:inputField value="{!User.CommunityNickname}"/>
                <!--<apex:inputField value="{!User.userType}"/-->       
            </apex:pageBlockSection>
        
           <apex:pageBlockSection >
           
                <apex:inputField value="{!User.Phone}"/>
                <apex:inputField value="{!User.Extension}"/>
                <apex:inputField value="{!User.Fax}"/>
                <apex:inputField value="{!User.EmployeeNumber}"/>
                <apex:inputField value="{!User.FederationIdentifier}"/>
                <apex:inputField value="{!User.Division}"/>
                <apex:inputField value="{!User.Department}"/>                   
           
           </apex:pageBlockSection>
           
            <apex:pageBlockSection title="Liscence Information" collapsible="True" columns="2" >
                <apex:pageBlockSectionItem >

          <apex:outputLabel value="License" for="lic"></apex:outputLabel>

              <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                 <apex:selectOptions value="{!license}"/>
                    <apex:actionSupport event="onchange" rerender="selectedProfileId"/>
           </apex:selectList>

           </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                      <apex:selectList value="{!User.ProfileId}" multiselect="false" size="1" id="selectedProfileId">
                       <apex:selectOptions value="{!profile}" />
                           </apex:selectList>

                         </apex:pageBlockSectionItem>

            </apex:pageBlockSection>
             
             <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">

                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/>
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>

               </apex:pageBlockSection>

                     </apex:pageBlock>
      
    </apex:form>
  
</apex:page>




My controller:
public class CreateUser{
    private final User user;
    public createuser(Apexpages.standardcontroller cont){
    this.user=(user)cont.getrecord(); 
    //user.UserType=[select id ,name from UserLicense where name = 'Chatter Free'].name; 
    //user.ProfileId=[select id from Profile where name='Chatter Free User'].id;  
    }
    
    Public list<selectOption> getLicense(){
        List<selectOption> options=new List<selectoption>();
        options.add(new selectOption('', '- None -')); //for default values
        for(UserLicense u:[Select id,Name from UserLicense]){
            options.add(new selectoption(u.id,u.name));      
        
        }
        
        return options; 
    
    
    }    
    public List<selectOption> getProfile() {

      List<selectOption> options1 = new List<selectOption>(); //new list for holding all of the picklist options

      options1.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below

   
   for (Profile users1 :[SELECT Id,Name FROM Profile] )  {   

              options1.add(new selectOption(users1.Id, users1.Name)); //for all records found - add them to the picklist options

      }
    
    return options1;
    }
    }
when i use SeeAllData=true on test class, can able to query the records from org, and able to insert, update but not able to delete, why ?
see the below test class after delete statement assert statement is failing, can you please look into this .....  
@IsTest(SeeAllData=true)
private class TestClassOnVenkat{
  static testmethod void InsertRec(){
   venkat__c a=[select id,name from venkat__c where name='name value'];
   Venkat__c b=a.clone();
   b.name='cloneed name value';
   Test.startTest();
   insert b;
   venkat__c c=[select id,name from venkat__c where name='cloneed ZZZZZ'];
   System.assert(c != Null);   
   c.name='Update name value';
   update c;
   System.assert(c.name=='cloneed name value');   
   delete c;
   System.assert(c == null);   
   Test.stopTest();  
  }
}

Thanks
  • May 13, 2015
  • Like
  • 0
Hi everyone!  I am looking for people to build a trusted working relationship with; people that I can turn to that will help me execute my projects.  

My goal is to have a group of us that all work together, as projects arise, based on our individual specialties.  Right now I am acting as the project manager, technical architect, designer, builder, and administator for each one of my clients; its too much! 

If you are a Certified Developer or Certified Administrator with at least 5 years of experience, live in the U.S., and would like to become part of a trusted team of excellence, please send me your resume along with your hourly rate detail.   (dea@deasimon.com) 

This is a contract position that is ad-hoc in nature, no guarantee of consisent work is given at this time but you will be the first I call when assistance is needed.  My apologies but no oveseas applicants will be considered, previous experience with significant differences in timezones has proven to be too difficult to manage.