• Sam1980
  • NEWBIE
  • 90 Points
  • Member since 2014
  • Sam1980

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 4
    Replies
I am Salesforce.com certified Force.com Developer.
My Certified expired in 2014.

How do i renew it ?

As i am not able to see any options for renewing the certificate
I am reading Json from a url the output of the JSON is like below

JSON String:
{"id":"1","name":"asdadsra","username":"karura","password":"0s01","supplierid":"3","pin":"pin","location":"Kiambu","telephone":"333333","email":"abc@test.co","gender":"1","type":"1","lastLogin":"1412770127","createtime":"0","salesforcestatus":"1"}

And i want to add the data in Custom Object: Shop__c

Custom Field:
id : Shop_ID__c
name : Name
username : User_Name__c
password : Password__c
supplierid : Supplier_ID__c
pin : Pin__c
location : Location__c
telephone : Telephone__c
email : Email__c
gender : Gender__c
type : Type__c
lastLogin : Last_Login__c
createtime : Create_Time__c
                salesforcestatus : Salesforce_Status__c

Please advise how to add data in custom objects.
I have JSon feed at http://tinyurl.com/mpnb2fo

Want to diplay data in VF page with paging.. what is the best way to do ?

I have tried to hard code the data, in my Apex code, is there any another way to read JSON data? But if we didn't provide hard coded data then how apex class can read JSON data? How we can send JSON data to apex class?

Please help
  • September 25, 2014
  • Like
  • 0
I have a JSON feed  that i want to read and insert into Contact and Companies Object.

Its Very Large JSON Data. What is the best way to do it ? Shall i

1) Create some Sort of schedule in Salesforce?
2)  read chunk of data and insert/update?

Any code would be helpful

Here is my Json Feed url http://tinyurl.com/mpnb2fo
  • September 25, 2014
  • Like
  • 0
When I try to fetch number of Cases for any particular Client It gives me exactly number of cases for that client but I didn’t get data for case in edit mode when I run my code.

User-added image

My Visual Force and apex Code as beloved:

<apex:page controller="ShowPaggingInChaiCtrlNew">
    <apex:form >
        <apex:pageBlock id="pb">
           <apex:image id="theImage" value="{!$Resource.SANCRUCaseLogo}" width="950" height="110"/>
           <br> </br>
                <div id="ChaiCaseDiv">
            <apex:pageBlockSection title="Update,Open or View a Case File" id="pbs2">
            <apex:pageMessages id="msg"></apex:pageMessages>
            <apex:pagemessages ></apex:pagemessages>
            <apex:inputField value="{!chaicase.SANClientID__c}"/>    
            <apex:inputField value="{!chaicase.Case_Open_Date__c}"/>
            <apex:inputField value="{!chaicase.Case_Worker__c}" />
            <apex:inputField value="{!chaicase.Next_Follow_Up_Date__c}" />
            <apex:inputField value="{!chaicase.Current_Case_Status__c}" />
             <apex:inputField value="{!chaicase.Case_Close_Date__c}" />
             <apex:inputField value="{!chaicase.Case_Notes__c}" />
            </apex:pageBlockSection>
        </div>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="First"   action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Previous" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Next" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Last" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>
                <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                <apex:commandButton value="Close Form" action="{!GoTOClientData}" id="closeformId"/>
                <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                </apex:outputPanel>
            </apex:panelGrid>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Apex Controller: 
public class ShowPaggingInChaiCtrlNew {

    public CHAI_Case__c chaicase{get;set;}
    
    public SAN_Client__c san{get;set;}
    
    public List<CHAI_Case__c> chaicaseList{get;set;}
    
    public ID cID{get;set;}
    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    
    public ApexPages.StandardSetController setCon
     {
        get{
            
            if(setCon == null){
                size = 1;
                cID = ApexPages.currentPage().getParameters().get('id');
                string queryString = 'select id, SANClientID__c,Case_Open_Date__c,Case_Worker__c,Next_Follow_Up_Date__c,Current_Case_Status__c,Case_Close_Date__c,Case_Notes__c from CHAI_Case__c where SANClientID__c =: cID order by CreatedDate';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
            }
            return setCon;
        }set;
    }
     
    Public List <CHAI_Case__c> getCHAICases(){
        List<CHAI_Case__c>chcaseList= new List<CHAI_Case__c>();
        for(CHAI_Case__c c: (List<CHAI_Case__c>)setCon.getRecords())
            chcaseList.add(c);
        return chcaseList;
    }
     
    public pageReference refresh() {
        setCon = null;
        getCHAICases();
        setCon.setPageNumber(1);
        return null;
    }
    
    public PageReference Previous() {
    return new   pageReference('/apex/ViewAllChaiCases?id='+ApexPages.currentPage().getParameters().get('id'));
    }
    
    public PageReference gotoEdit() {
    cID = ApexPages.currentPage().getParameters().get('CaseID');
    return new PageReference('/apex/EditChaiCases?id='+cID);
       
    }
    
    public PageReference GoTOClientData() {
        san= [select id,Name,First_Name__c,Middle_Name__c,Last_Name__c,Gender__c,Home_Street_Address__c,Home_City__c,Home_State__c,
            Home_Phone_Number__c,Home_Zip_Code__c,Work_Phone_Number__c from 
            SAN_Client__c where id =: ApexPages.currentPage().getParameters().get('id')];
        PageReference pref = new ApexPages.StandardController(san).view();
        return pref;
    }
}

  • September 02, 2014
  • Like
  • 0
How to  write SOQL to show next and previously added case data. How can i fetch record according to created date. What would be the SOQL to fetch data.
Please check  below.

User-added image
I want to build my own app but i am confused to which one and what is required.

1) To build and publish an Salesforce App do i need to become ISV partner, do you need to pay any fees for that?

2) I am also thinking to build my own mobile app and then publish it on salesforce, offcourse i want to build a unique app and have few ideas. But how do i check on salesforce that my app idea is really unique and its not already built?

3) I want to make my App Free

Not sure why i am getting this error, please help

System.NullPointerExeption: Attempted to upsert a null list
Error s in expressoin {!save} in component < apex: commandButton> in page oladdclient: Class.OLaddcientctrl.save:Line 50, column 1


Here is the Apex code


<apex:page controller="OLaddClientctrl">
   <script>
            function CloseChaiData(){
                document.getElementById("ChaiDiv").style.display = 'none'; 
               document.getElementById('ClientDiv').style.display='';
               return false;
            }
            function ShowChaiCaseData(){
                document.getElementById("ChaiDiv").style.display = 'none'; 
                document.getElementById('ChaiCaseDiv').style.display='';
               return false;
            }
</script>
<apex:pageMessages ></apex:pageMessages>
  <apex:form >
      <apex:pageBlock >
      <div id="ClientDiv" style="display: none;">
      <apex:pageblockSection title="Client Basic Information">
                <apex:inputField value="{!san.Name}" />
                <apex:inputField value="{!san.First_Name__c}" />
                <apex:inputField value="{!san.Middle_Name__c}" />
                <apex:inputField value="{!san.Last_Name__c}" />
                <apex:inputField value="{!san.Gender__c}" />
                <apex:inputField value="{!san.Home_Phone_Number__c}" />
                <apex:inputField value="{!san.Home_Street_Address__c}" />
                <apex:inputField value="{!san.Home_City__c}" />
                <apex:inputField value="{!san.Home_State__c}" />
            <apex:inputField value="{!san.Home_Zip_Code__c}" />
            <apex:inputField value="{!san.Work_Phone_Number__c}" />

</apex:pageblockSection>
</div>
      
          <div id="ChaiDiv">
           
            <apex:pageBlockSection title="ADD/VIEW CHAI DATA" >
            <apex:inputField value="{!chai.SANClientID__c}" />
            <apex:inputField value="{!chai.Spouse_Immigration_Status__c}" />
            <apex:inputField value="{!chai.Spouse_First_name__c}" />
            <apex:inputField value="{!chai.Spouse_Health_Insurance__c}" />
            <apex:inputField value="{!chai.Spouse_Last_name__c}" />
            <apex:inputField value="{!chai.Type_of_Health_Insurance__c}" />
            <apex:inputField value="{!chai.Spouse_Gender__c}" />
            <apex:inputField value="{!chai.Spouse_last_Dr_Visit__c}" />
            <apex:inputField value="{!chai.Spouse_DOB__c}" />
            <apex:inputField value="{!chai.Spouse_reason_for_last_Dr_Visit__c}" />
            <apex:inputField value="{!chai.Spouse_Primary_Language__c}" />
            <apex:inputField value="{!chai.Spouse_Education__c}" />
            <apex:inputField value="{!chai.Income_per_month__c}" />
            
            <apex:inputField value="{!chai.Spouse_Income_per_month__c}" />
            <apex:inputField value="{!chai.Spouse_Yrs_in_US__c}" />
            <apex:inputField value="{!chai.Total_Household_Income__c}" />
            <apex:inputField value="{!chai.Spouse_Ethnicity__c}" />
           </apex:pageBlockSection>
           <apex:pageBlockSection title="Information">
            <apex:inputField value="{!chai.Last_Doctors_Appointment__c}" />
            <apex:inputField value="{!chai.Health_Insurance__c}" />
            <apex:inputField value="{!chai.Reason_for_last_Dr_Visit__c}" />
            <apex:inputField value="{!chai.Type_of_Health_Insurance__c}" />
            
            </apex:pageBlockSection>
         </div>
         
         <div id="ChaiCaseDiv" style="display: none;">
            <apex:pageBlockSection title="Update,Open or View a Case File">
            <apex:inputField value="{!chaicase.SANClientID__c}" />    
            <apex:inputField value="{!chaicase.Case_Open_Date__c}" />
            <apex:inputField value="{!chaicase.Case_Worker__c}" />
            <apex:inputField value="{!chaicase.Next_Follow_Up_Date__c}" />
            <apex:inputField value="{!chaicase.Current_Case_Status__c}" />
             <apex:inputField value="{!chaicase.Case_Close_Date__c}" />
             <apex:inputField value="{!chaicase.Case_Notes__c}" />
               
            </apex:pageBlockSection>
        </div>
        
         <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="CHAI Cases" onclick="ShowChaiCaseData(); return false;"/>
            <apex:commandButton value="Close Form" action="{!GoTOClientData}"/>
         </apex:pageBlockButtons>
      </apex:pageBlock>
  </apex:form>
</apex:page>















public class OLaddClientctrl 
{
    public SAN_Client__c san{get;set;}
    public ID sID{get;set;}
    public CHAI__c chai{get;set;}
    public CHAI_Case__c chaicase{get;set;}
    private void addError (string msg) 
   {
    ApexPages.addMessage (new ApexPages.Message(ApexPages.Severity.ERROR,msg));
    }
    
    public OLaddClientctrl ()
{
        san= [select        id, Name, First_Name__c, Middle_Name__c, Last_Name__c, Gender__c,  Home_Street_Address__c, Home_City__c,Home_State__c,
        Home_Phone_Number__c,Home_Zip_Code__c,Work_Phone_Number__c from 
        SAN_Client__c where id =: ApexPages.currentPage().getParameters().get('id')];     
            try
              {     
                    chai = [select id, SANClientID__c, Spouse_Immigration_Status__c, Spouse_First_name__c, Spouse_Health_Insurance__c, Spouse_Last_name__c,
Spouse_Gender__c, Spouse_last_Dr_Visit__c, Spouse_DOB__c, Spouse_reason_for_last_Dr_Visit__c,Spouse_Primary_Language__c,Spouse_Education__c,              Income_per_month__c,Spouse_Income_per_month__c,Spouse_Yrs_in_US__c,Total_Household_Income__c,Spouse_Ethnicity__c,Last_Doctors_Appointment__c,
 Health_Insurance__c,Reason_for_last_Dr_Visit__c,Type_of_Health_Insurance__c from 
                    CHAI__c where SANClientID__c =: ApexPages.currentPage().getParameters().get('id')];
                    chaicase = [select id, SANClientID__c, Case_Open_Date__c, Case_Worker__c, Next_Follow_Up_Date__c, Current_Case_Status__c,
                    Case_Close_Date__c,Case_Notes__c from 
                    CHAI_Case__c where SANClientID__c =: ApexPages.currentPage().getParameters().get('id')];
              }
              catch(Exception e)
              {
                ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'No Record Found' );
                ApexPages.addmessage(msg);       
              }
    } 
    public SAN_Client__c getsan(){
    return san;
    }
    public PageReference save() {
        try
        {
        upsert san;
        upsert chai;
        upsert chaicase;
        }
        catch(DmlException e)
        {
           System.debug('The following exception has occurred: ' + e.getMessage());
           addError ('Could not save changes: '  + e.getMessage());  
        }
        return new pageReference('/apex/oldAddClient?id='+ApexPages.currentPage().getParameters().get('id'));
    }
    
    public PageReference GoTOClientData() {
        PageReference pref = new ApexPages.StandardController(san).view();
        return pref;
    }
    
    
}

As per the image below is it possible to catch the warning message and Hide the button and the form below it ? How do i do it ?

User-added image
I have created a form  ( Leads) where the data gets inserted .

Every Lead will have a Unique Lead ID.

I have another form where i add salesperson under that Lead, so in the drop down first lead is selected then the data of salesperon is added.

My question is i want to Add only ONE salesperson per lead.

So how do i manage this what is the best approach ? To show validation error that you have already added a salesperson... under LEADID.

Any code?
Is it possible to Add a New button on the right of Addition Information in Views Page, link that button to a url with dynamically appended clientID ?

User-added image
I have developed a VF Component and want to do the following so was wondering if its possible and any code will be great help

So if The logged in persons Role is  NOT a  Programmer i want to display the following BLOCK

<apex:component  controller="MyController">   
    <apex:pageBlock title="Products">
        <apex:pageBlockTable >
        </apex:pageBlockTable>
    </apex:pageBlock>

and If the role is programmer i want to display a message

<div> You are not the user </div>

1) How to check the role of current logged in used in APEX
2) How to use IF Else Condition in APEX
Have a Customer Portal where in one of the Visual force page some component is used.

I have the componenet/controller name, but not sure how to find it ?

Please help in finding the right approach.

Current Scenario, i have a mysql database which i wanted to move all the data and users to Salesforce.. here are the table details

Client Table  . Each client will be assigned one or more department like software, QA,PHP etc.  Many custom fields

Admin users table : Main admin with acess to all cleint.. Some users will be assigned more or one department and accordingly he will have acess to respective clients.

Client_department table : in this we have to collect more information department wise which will be linked with client id from clients table

Cleint_department_xref table : in this we have to collect information department wise which can occur more than once for each cleint id.

Cases table : in this we want to create ticket or cases each client wise

All tables have custom fields . so need to know what is the best approach to setup database and respective forms in salesforce.

Do we have to use default sobject or do we have to create custom object or a combination of  both.
Not sure where to start
I am getting Error at the line 23 which is in Bold below

(ContactId = c.Id,CampaignId = '7018000tyyy'));

Here is the whole code
trigger triggerContactCreateCampMember on Contact (after update) {

   List<CampaignMember> CampaignMember = new List<CampaignMember>();
   List<Contact> ContactsToAdd = new List<Contact>();
    
    Set<Id> contId= new Set<Id>();
     if(Trigger.isUpdate)
    //Store Contact ID
    for(Contact contact: Trigger.new)
    {
       if (contact.LeadSource =='Web' ) 
       contId.add(contact.ID);
    }
        List<Contact> c = new List<Contact> ([SELECT c.Id,c.AccountId From Contact c
        WHERE Id IN :contId]);

        for (Contact con : c) {

        if(contId.size() > 0)
       {
       
           CampaignMember.add(new CampaignMember
                    (ContactId = c.Id,CampaignId = '7018000tyyy'));
                      insert CampaignMember;
        }
        }
}


I used this tutorial from https://developer.salesforce.com/page/Authenticating_Users_on_Force.com_Sites to create a Login page in Visualforce with Username & Password fields and Buttons to have are: SAVE, CANCEL.

I have tried but login fails. Showing error as: Error: Your login attempt has failed. Make sure the username and password are correct.

Here is the Visualforce markup for this page, in this case the source we are reviewing it is a component that is placed on the login page that you create within your site.

<apex:component controller="SiteLoginController" id="loginComponent">
    <apex:form id="loginForm" forceSSL="true">
        <apex:outputPanel layout="block">
            <apex:pageMessages id="error" />
            <apex:panelGrid columns="2" style="margin-top:1em;">

                <apex:outputLabel value="{!$Label.site.username}" for="username" />
                <apex:inputText id="username" value="{!username}" />
                <apex:outputLabel value="{!$Label.site.password}" for="password" />
                <apex:inputSecret id="password" value="{!password}" />

                <br />
                <apex:commandButton action="{!login}"
                    value="{!$Label.site.login_button}" id="loginButton" />
                <br />
                <apex:panelGroup id="theLinks">

                    <apex:outputLink value="{!$Page.ForgotPassword}">
                        {!$Label.site.forgot_your_password_q}
                    </apex:outputLink>

                    <apex:outputText value=" | "        
                        rendered="{!$Site.RegistrationEnabled}" />
                    <apex:outputLink value="{!$Page.SiteRegister}"
                        rendered="{!$Site.RegistrationEnabled}">
                        {!$Label.site.new_user_q}
                    </apex:outputLink>

                </apex:panelGroup>
            </apex:panelGrid>
        </apex:outputPanel>
    </apex:form>
</apex:component>
Apex Code for the controller, SiteLoginController:
public class SiteLoginController {
    public String username {get; set;}
    public String password {get; set;}

    public PageReference login() {
        String startUrl = System.currentPageReference().getParameters().get('startURL');
        return Site.login(username, password, startUrl);
    }

       public SiteLoginController () {}

    public static testMethod void testSiteLoginController () {
        // Instantiate a new controller with all parameters in the page
        SiteLoginController controller = new SiteLoginController ();
        controller.username = 'test@salesforce.com';
        controller.password = '123456';

        System.assertEquals(controller.login(),null);                           
    }    
}


What is the maximum number of Custom Apps that can be created using the Developer Edition?

In Developer Edition can  managed package be created? If not in which edition
I am reading Json from a url the output of the JSON is like below

JSON String:
{"id":"1","name":"asdadsra","username":"karura","password":"0s01","supplierid":"3","pin":"pin","location":"Kiambu","telephone":"333333","email":"abc@test.co","gender":"1","type":"1","lastLogin":"1412770127","createtime":"0","salesforcestatus":"1"}

And i want to add the data in Custom Object: Shop__c

Custom Field:
id : Shop_ID__c
name : Name
username : User_Name__c
password : Password__c
supplierid : Supplier_ID__c
pin : Pin__c
location : Location__c
telephone : Telephone__c
email : Email__c
gender : Gender__c
type : Type__c
lastLogin : Last_Login__c
createtime : Create_Time__c
                salesforcestatus : Salesforce_Status__c

Please advise how to add data in custom objects.
I am reading Json from a url the output of the JSON is like below

JSON String:
{"id":"1","name":"asdadsra","username":"karura","password":"0s01","supplierid":"3","pin":"pin","location":"Kiambu","telephone":"333333","email":"abc@test.co","gender":"1","type":"1","lastLogin":"1412770127","createtime":"0","salesforcestatus":"1"}

And i want to add the data in Custom Object: Shop__c

Custom Field:
id : Shop_ID__c
name : Name
username : User_Name__c
password : Password__c
supplierid : Supplier_ID__c
pin : Pin__c
location : Location__c
telephone : Telephone__c
email : Email__c
gender : Gender__c
type : Type__c
lastLogin : Last_Login__c
createtime : Create_Time__c
                salesforcestatus : Salesforce_Status__c

Please advise how to add data in custom objects.
As per the image below is it possible to catch the warning message and Hide the button and the form below it ? How do i do it ?

User-added image
I have developed a VF Component and want to do the following so was wondering if its possible and any code will be great help

So if The logged in persons Role is  NOT a  Programmer i want to display the following BLOCK

<apex:component  controller="MyController">   
    <apex:pageBlock title="Products">
        <apex:pageBlockTable >
        </apex:pageBlockTable>
    </apex:pageBlock>

and If the role is programmer i want to display a message

<div> You are not the user </div>

1) How to check the role of current logged in used in APEX
2) How to use IF Else Condition in APEX