• Ghulam Chaudhary
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hi everyone,
I created a class that convert Account Record data into JSON and it is working correctly, but if any field values is null, then it throughs an error:"field is null".
In this class,created a map and get all fields that I need but map is containing only field values that are not null and map is not containing fields that are null,so I am facing this problem.
I am sharing my class,please have a look and help me to overcome this problem.

global class AccountRecs 
    {

    //  public static void fetchAccounts(Map<id,account> MapAcc) 
      public static void fetchAccounts(id ids) 
      {
          Map<Id,Account> lstAccount = new Map<Id,Account>([select Id,Name,PT_Company_Name__c,PT_Email__c,PT_Merchant_SPOC_Mobile__c,
          PT_Merchant_SPOC_Name__c,Phone_Verified__c,PT_Landline_Number__c,PT_Order_Dispatch_Time__c,PT_Lead_ID__c, PT_BD_SPOC_Email_ID__c,
          PT_Vendor_spoc_email__c,PT_Vendor_spoc_mobile_number__c,Verification_SPOC_Email__c,PT_MOB_Doc_SPOC_Email_ID__c,PT_MOB_MID_SPOC_Email__c,
          PT_SMT_Manager_Email__c,Business_Info__c,Catalog_Received__c,Warehouse_Added__c,Finance_Kyc__c,PT_Company_Address__c,
          State_CompanyAddress__c,PT_City__c,PT_Pin_Code__c,Zip_Code__c,PT_Beneficiary_Name_in_Bank__c,PT_Bank_IFSC_Code__c,
          PT_Account_No__c, Account_No_international__c,PT_Bank_Name__c,PT_Branch_Name__c,PT_PAN__c,PT_Lead_Stage__c,PT_VAT_TIN__c,
          PT_Warehouse_City__c,Country_WarehouseAddress__c,PT_Pin_Code_Warehouse__c,PT_Warehouse_State__c,PT_Seller_Name__c,
          PT_Additional_Details__c,PT_CAT_Rev_SPOC_Email_ID__c,PT_CAT_Proc_SPOC__c,PT_SMT_SPOC_Email_Id__c
          
          //from account where id in :MapAcc.keyset() ]);
          from account where id =: ids ]);
          
         system.debug('Account--->'+lstAccount);
          
          If(lstAccount.isempty() == false){
          
          JSONGenerator gen = JSON.createGenerator(true);
          for(Account Acc: lstAccount.values()){
          //start 
          gen.writeStartObject();
          
          gen.writeFieldName('Merchant');
             gen.writeStartObject();
              if(Acc.Name!='')
              {
                gen.writeStringField('Name',Acc.Name);
              }
              else
              {
                gen.writeStringField('Name','');
              }
              
              if(Acc.PT_Seller_Name__c!='' || Acc.PT_Seller_Name__c <> null)
              {
                gen.writeStringField('Dispaly_Name',Acc.PT_Seller_Name__c);
              }
              else
              {
                gen.writeStringField('Dispaly_Name','');
              }
              if(Acc.PT_Company_Name__c!='' || acc.pt_company_name__c != null)
              {
                gen.writeStringField('Company_Name',Acc.PT_Company_Name__c);
              }
              else
              {
               gen.writeStringField('Company_Name','');
              }
              if(Acc.PT_Email__c!='')
              {
                gen.writeStringField('Email_Id',Acc.PT_Email__c);
              }
              else
              {
                gen.writeStringField('Email_Id','');
              }
              if(Acc.PT_Merchant_SPOC_Mobile__c!='')
              {
                gen.writeStringField('Mobile Number',Acc.PT_Merchant_SPOC_Mobile__c);
              }
              else
              {
                gen.writeStringField('Mobile Number','');
              }
              if(Acc.Phone_Verified__c!=null)
              {
                gen.writeBooleanField('Phone_Varified',Acc.Phone_Verified__c);
              }
              else
              {
                gen.writeBooleanField('Phone_Varified',null);
              }
              if(Acc.PT_Landline_Number__c!='')
              {
                gen.writeStringField('Landline_Number',Acc.PT_Landline_Number__c);
              }
              else
              {
                gen.writeStringField('Landline_Number','');
              }
              if(Acc.PT_Order_Dispatch_Time__c!='')
              {
                gen.writeStringField('Max_Shipping_Days',Acc.PT_Order_Dispatch_Time__c);
              }
              else
              {
                gen.writeStringField('Max_Shipping_Days','');
              }
              if(Acc.PT_Merchant_SPOC_Name__c!='')
              {
                gen.writeStringField('am_name',Acc.PT_Merchant_SPOC_Name__c);
              }
              else
              {
                gen.writeStringField('am_name','');
              }
              if(Acc.PT_Email__c!='')
              {
                gen.writeStringField('am_email_id',Acc.PT_Email__c);
              }
              else
              {
                gen.writeStringField('am_email_id','');
              }
              if(Acc.PT_Merchant_SPOC_Mobile__c!='')
              {
                gen.writeStringField('am_mobile_number',Acc.PT_Merchant_SPOC_Mobile__c);
              }
              else
              {
                gen.writeStringField('am_mobile_number','');
              }
              if(Acc.PT_Additional_Details__c!='')
              {
                gen.writeStringField('Info',Acc.PT_Additional_Details__c);
              }
              else
              {
                gen.writeStringField('Info','');
              }
              if(Acc.PT_Lead_ID__c!='')
              {
                gen.writeStringField('Lead_Id',Acc.PT_Lead_ID__c);
              }
              else
              {
                gen.writeStringField('Lead_Id','');
              }
              if(Acc.PT_BD_SPOC_Email_ID__c!='')
              {
                gen.writeStringField('Spoc_Email',Acc.PT_BD_SPOC_Email_ID__c);
              }
              else
              {
                gen.writeStringField('Spoc_Email','');
              }
                
           gen.writeFieldName('Spoc_email_smt');
               gen.writeStartObject();
               if(Acc.PT_MOB_Doc_SPOC_Email_ID__c!='')
               {
                 gen.writeStringField('MOBDocVerifierEmail_Id',Acc.PT_MOB_Doc_SPOC_Email_ID__c);
               }
               else
               {
                 gen.writeStringField('MOBDocVerifierEmail_Id','');
               }
               if(Acc.PT_MOB_MID_SPOC_Email__c!='')
               {
                 gen.writeStringField('MOBMerchantCreatorEmail_Id',Acc.PT_MOB_MID_SPOC_Email__c);
               }
               else
               {
                  gen.writeStringField('MOBMerchantCreatorEmail_Id','');
               }
               if(Acc.PT_CAT_Rev_SPOC_Email_ID__c!='')
               {
                 gen.writeStringField('CATReviewerEmail_Id',Acc.PT_CAT_Rev_SPOC_Email_ID__c);
               }
               else
               {
                 gen.writeStringField('CATReviewerEmail_Id','');
               }
               if(Acc.PT_CAT_Proc_SPOC__c!='')
               {
                 gen.writeStringField('CATProctorEmail_Id',Acc.PT_CAT_Proc_SPOC__c);
               }
               else
               {
                 gen.writeStringField('CATProctorEmail_Id','');
               }
               if(Acc.PT_SMT_Manager_Email__c!='')
               {
                 gen.writeStringField('SMTManagerEmail_Id',Acc.PT_SMT_Manager_Email__c);
               }
               else
               {
                 gen.writeStringField('SMTManagerEmail_Id','');
               }
               if(Acc.PT_SMT_SPOC_Email_Id__c!='')
               {
                 gen.writeStringField('SMTExecEmail_Id',Acc.PT_SMT_SPOC_Email_Id__c);
               }
               else
               {
                 gen.writeStringField('SMTExecEmail_Id','');
               }
               gen.writeEndObject(); 
               if(Acc.PT_Lead_Stage__c!='')
               {
                 gen.writeStringField('Sf_State',Acc.PT_Lead_Stage__c);
               }
               else
               {
                 gen.writeStringField('Sf_State','');
               }
               if(Acc.Business_Info__c!=null)
               {
                 gen.writeBooleanField('Business_info',Acc.Business_Info__c);
               }
               else
               {
                 gen.writeBooleanField('Business_info',null);
               }
               if(Acc.Catalog_Received__c!=null)
               {
                 gen.writeBooleanField('Catalog_received',Acc.Catalog_Received__c);
               }
               else
               {
                 gen.writeBooleanField('Catalog_received',null);
               }
               if(Acc.Warehouse_Added__c!=null)
               {
                 gen.writeBooleanField('Warehouse_added',Acc.Warehouse_Added__c);
               }
               else
               {
                 gen.writeBooleanField('Warehouse_added',null);
               }
               if(Acc.Finance_Kyc__c!=null)
               {
                 gen.writeBooleanField('Finance_kyc',Acc.Finance_Kyc__c);
               }
               else
               {
                 gen.writeBooleanField('Finance_kyc',null);
               }
                 
             gen.writeEndObject();
      
          gen.writeFieldName('Address');
            gen.writeStartObject();
            if(Acc.PT_Company_Address__c!='')
            {
               gen.writeStringField('Address',Acc.PT_Company_Address__c);
            }
            else
            {
               gen.writeStringField('Address','');
            }
            if(Acc.PT_City__c!='')
            {
               gen.writeStringField('City',Acc.PT_City__c);
            }
            else
            {
              gen.writeStringField('City','');
            }
            if(Acc.State_CompanyAddress__c!='')
            {
               gen.writeStringField('State',Acc.State_CompanyAddress__c);
            }
            else
            {
               gen.writeStringField('State','');
            }
            if(Acc.PT_Pin_Code__c!='')
            {
               gen.writeStringField('Pin_code',Acc.PT_Pin_Code__c);
            }
            else
            {
              gen.writeStringField('Pin_code','');
            }
            gen.writeEndObject();
       
           gen.writeFieldName('Finance');
            gen.writeStartObject(); 
            if(Acc.PT_Beneficiary_Name_in_Bank__c!='')
            {
                gen.writeStringField('Beneficiary_name',Acc.PT_Beneficiary_Name_in_Bank__c);
            }
            else
            {
               gen.writeStringField('Beneficiary_name','');
            }
            if(Acc.PT_Account_No__c!='')
            {
               gen.writeStringField('Bank_account_no',Acc.PT_Account_No__c);
            }
            else
            {
               gen.writeStringField('Bank_account_no','');
            }
            if(Acc.PT_Bank_IFSC_Code__c!='')
            {
               gen.writeStringField('IFSC_code',Acc.PT_Bank_IFSC_Code__c);
            }
            else
            {
               gen.writeStringField('IFSC_code','');
            }
            if(Acc.PT_Bank_Name__c!='')
            {
                 gen.writeStringField('Bank_name',Acc.PT_Bank_Name__c);
            }
            else
            {
                gen.writeStringField('Bank_name','');
            }
            if(Acc.PT_Branch_Name__c!='')
            {
                 gen.writeStringField('Branch_name',Acc.PT_Branch_Name__c);
            }
            else
            {
                 gen.writeStringField('Branch_name','');
            }
            gen.writeEndObject();
          
          gen.writeFieldName('Kyc');
            gen.writeStartObject();
            if(Acc.PT_PAN__c!='')
            {
                 gen.writeStringField('PAN_Card_No',Acc.PT_PAN__c);
            }
            else
            {
                gen.writeStringField('PAN_Card_No',''); 
            }
            if(Acc.PT_VAT_TIN__c!='')
            {
                 gen.writeStringField('VAT_no',Acc.PT_VAT_TIN__c);
            }
            else
            {
               gen.writeStringField('VAT_no',''); 
            }
            gen.writeEndObject();
        
            gen.writeFieldName('Warehouse');
              gen.writeStartArray();
            
               gen.writeStartObject();
               if(Acc.Country_WarehouseAddress__c!='')
               {
                 gen.writeStringField('Address',Acc.Country_WarehouseAddress__c);
               }
               else
               {
                 gen.writeStringField('Address','');
               }
               if(Acc.PT_Warehouse_State__c!='')
               {
                 gen.writeStringField('State',Acc.PT_Warehouse_State__c);
               }
               else
               {
                 gen.writeStringField('State',''); 
               }
               if(Acc.PT_Warehouse_City__c!='')
               {
                 gen.writeStringField('City',Acc.PT_Warehouse_City__c);
               }
               else
               {
                 gen.writeStringField('City','');
               }
               if(Acc.PT_Pin_Code_Warehouse__c!='')
               {
                 gen.writeStringField('Pin_code',Acc.PT_Pin_Code_Warehouse__c);
               }
               else
               {
                 gen.writeStringField('Pin_code','');
               }
               gen.writeEndObject();
                
              gen.writeEndArray();
          gen.writeEndObject();
          String jsonString = gen.getAsString();
          System.debug('jsonString:'+jsonString);
          }
          
          }
          
      }
    }

its working fine but only non-null fields,suppose I have only two fields-1.Name and other is 2. Company name,if both fields have a value then it generates JSON file like-
{
"Name":"Ghulam",
"Company name":"Paytm"
}

but,if any field is null then it throughs error.
And I want to do if any field is null then also generate JSON file and dispaly the null value in JSON like below--
suppose "Company name" field is null then JSON will like-
{
"Name":"Ghulam",
"Company name":" "
}

I hope someone help me..
Thanks,
Ghulam
Hi everyone,

Its my first time when I am creating an REST API to create a case from a third party application( MyItemApp) based on MyItemApp's Fields (like Item Id,Merchant Id). 
When we get Item Id and Merchant Id it will create a case in salesforce.

my code is below but I am unable to do it please help me.... 

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

global class Paytm_SellerPanel_CaseCreation{
global static string message;
@HttpPost
global static string Paytm_SellerPanel_CaseCreation()

    RestRequest req = RestContext.request;
    RestResponse res = Restcontext.response;

    string RespBody=RestContext.request.requestBody.tostring().trim();
    system.debug('respbody    '+respbody);

    records deserializedBody =(records)JSON.deserialize(RespBody, records.class);
    system.debug('deserializedBody  '+deserializedBody);
    createcase(deserializedBody);
    system.debug('message new'+message);
    return message;
}
global class records{
    public string timestamp{get;set;}
    public String addcat_id{get;set;}
    public list<fields> fields{get;set;}
    public string merchant_id{get;set;}
    public string item_id{get;set;}
}

public List<fields> fields;

public class fields
{
    public string ApiName{get;set;}
    public string label{get;set;}
    public string value{get;set;}
    public string datatype{get;set;}
}

public static string createcase(records CasRecords) 
{
    string uploadOn='';
   // string message;
    string out='true';
    string chk='';
    string teamName='';
    string TemplateName='';
    boolean CaseMgm=true;
    system.debug('CasRecords   '+CasRecords);
  }
}
please help me if possible

thanks,
Ghulam
Hi Everyone,

I have a force.com site page named "my_merchent_c" and this page has two custom fields,one is "Product Listing" and other is "Super Product listing".
I want to get these two fields values from "my_merchent__c" site page through URL and display on "MyPage__c" VF page.

I hope,anyone can help me..

Thanks,
Ghulam
Hi Everyone,

I am new in salesforce development and I want to create a trigger on Task, when I create a task and Choose an Account, after choose an Account and now I choose a Contact then Contact lookup only display  contacts in lookup window that are related to that particular account rather than all contacts related to all accounts.

I need your help, please suggest me.

thanks,
Ghulam

 
Hi everyone,
I created a class that convert Account Record data into JSON and it is working correctly, but if any field values is null, then it throughs an error:"field is null".
In this class,created a map and get all fields that I need but map is containing only field values that are not null and map is not containing fields that are null,so I am facing this problem.
I am sharing my class,please have a look and help me to overcome this problem.

global class AccountRecs 
    {

    //  public static void fetchAccounts(Map<id,account> MapAcc) 
      public static void fetchAccounts(id ids) 
      {
          Map<Id,Account> lstAccount = new Map<Id,Account>([select Id,Name,PT_Company_Name__c,PT_Email__c,PT_Merchant_SPOC_Mobile__c,
          PT_Merchant_SPOC_Name__c,Phone_Verified__c,PT_Landline_Number__c,PT_Order_Dispatch_Time__c,PT_Lead_ID__c, PT_BD_SPOC_Email_ID__c,
          PT_Vendor_spoc_email__c,PT_Vendor_spoc_mobile_number__c,Verification_SPOC_Email__c,PT_MOB_Doc_SPOC_Email_ID__c,PT_MOB_MID_SPOC_Email__c,
          PT_SMT_Manager_Email__c,Business_Info__c,Catalog_Received__c,Warehouse_Added__c,Finance_Kyc__c,PT_Company_Address__c,
          State_CompanyAddress__c,PT_City__c,PT_Pin_Code__c,Zip_Code__c,PT_Beneficiary_Name_in_Bank__c,PT_Bank_IFSC_Code__c,
          PT_Account_No__c, Account_No_international__c,PT_Bank_Name__c,PT_Branch_Name__c,PT_PAN__c,PT_Lead_Stage__c,PT_VAT_TIN__c,
          PT_Warehouse_City__c,Country_WarehouseAddress__c,PT_Pin_Code_Warehouse__c,PT_Warehouse_State__c,PT_Seller_Name__c,
          PT_Additional_Details__c,PT_CAT_Rev_SPOC_Email_ID__c,PT_CAT_Proc_SPOC__c,PT_SMT_SPOC_Email_Id__c
          
          //from account where id in :MapAcc.keyset() ]);
          from account where id =: ids ]);
          
         system.debug('Account--->'+lstAccount);
          
          If(lstAccount.isempty() == false){
          
          JSONGenerator gen = JSON.createGenerator(true);
          for(Account Acc: lstAccount.values()){
          //start 
          gen.writeStartObject();
          
          gen.writeFieldName('Merchant');
             gen.writeStartObject();
              if(Acc.Name!='')
              {
                gen.writeStringField('Name',Acc.Name);
              }
              else
              {
                gen.writeStringField('Name','');
              }
              
              if(Acc.PT_Seller_Name__c!='' || Acc.PT_Seller_Name__c <> null)
              {
                gen.writeStringField('Dispaly_Name',Acc.PT_Seller_Name__c);
              }
              else
              {
                gen.writeStringField('Dispaly_Name','');
              }
              if(Acc.PT_Company_Name__c!='' || acc.pt_company_name__c != null)
              {
                gen.writeStringField('Company_Name',Acc.PT_Company_Name__c);
              }
              else
              {
               gen.writeStringField('Company_Name','');
              }
              if(Acc.PT_Email__c!='')
              {
                gen.writeStringField('Email_Id',Acc.PT_Email__c);
              }
              else
              {
                gen.writeStringField('Email_Id','');
              }
              if(Acc.PT_Merchant_SPOC_Mobile__c!='')
              {
                gen.writeStringField('Mobile Number',Acc.PT_Merchant_SPOC_Mobile__c);
              }
              else
              {
                gen.writeStringField('Mobile Number','');
              }
              if(Acc.Phone_Verified__c!=null)
              {
                gen.writeBooleanField('Phone_Varified',Acc.Phone_Verified__c);
              }
              else
              {
                gen.writeBooleanField('Phone_Varified',null);
              }
              if(Acc.PT_Landline_Number__c!='')
              {
                gen.writeStringField('Landline_Number',Acc.PT_Landline_Number__c);
              }
              else
              {
                gen.writeStringField('Landline_Number','');
              }
              if(Acc.PT_Order_Dispatch_Time__c!='')
              {
                gen.writeStringField('Max_Shipping_Days',Acc.PT_Order_Dispatch_Time__c);
              }
              else
              {
                gen.writeStringField('Max_Shipping_Days','');
              }
              if(Acc.PT_Merchant_SPOC_Name__c!='')
              {
                gen.writeStringField('am_name',Acc.PT_Merchant_SPOC_Name__c);
              }
              else
              {
                gen.writeStringField('am_name','');
              }
              if(Acc.PT_Email__c!='')
              {
                gen.writeStringField('am_email_id',Acc.PT_Email__c);
              }
              else
              {
                gen.writeStringField('am_email_id','');
              }
              if(Acc.PT_Merchant_SPOC_Mobile__c!='')
              {
                gen.writeStringField('am_mobile_number',Acc.PT_Merchant_SPOC_Mobile__c);
              }
              else
              {
                gen.writeStringField('am_mobile_number','');
              }
              if(Acc.PT_Additional_Details__c!='')
              {
                gen.writeStringField('Info',Acc.PT_Additional_Details__c);
              }
              else
              {
                gen.writeStringField('Info','');
              }
              if(Acc.PT_Lead_ID__c!='')
              {
                gen.writeStringField('Lead_Id',Acc.PT_Lead_ID__c);
              }
              else
              {
                gen.writeStringField('Lead_Id','');
              }
              if(Acc.PT_BD_SPOC_Email_ID__c!='')
              {
                gen.writeStringField('Spoc_Email',Acc.PT_BD_SPOC_Email_ID__c);
              }
              else
              {
                gen.writeStringField('Spoc_Email','');
              }
                
           gen.writeFieldName('Spoc_email_smt');
               gen.writeStartObject();
               if(Acc.PT_MOB_Doc_SPOC_Email_ID__c!='')
               {
                 gen.writeStringField('MOBDocVerifierEmail_Id',Acc.PT_MOB_Doc_SPOC_Email_ID__c);
               }
               else
               {
                 gen.writeStringField('MOBDocVerifierEmail_Id','');
               }
               if(Acc.PT_MOB_MID_SPOC_Email__c!='')
               {
                 gen.writeStringField('MOBMerchantCreatorEmail_Id',Acc.PT_MOB_MID_SPOC_Email__c);
               }
               else
               {
                  gen.writeStringField('MOBMerchantCreatorEmail_Id','');
               }
               if(Acc.PT_CAT_Rev_SPOC_Email_ID__c!='')
               {
                 gen.writeStringField('CATReviewerEmail_Id',Acc.PT_CAT_Rev_SPOC_Email_ID__c);
               }
               else
               {
                 gen.writeStringField('CATReviewerEmail_Id','');
               }
               if(Acc.PT_CAT_Proc_SPOC__c!='')
               {
                 gen.writeStringField('CATProctorEmail_Id',Acc.PT_CAT_Proc_SPOC__c);
               }
               else
               {
                 gen.writeStringField('CATProctorEmail_Id','');
               }
               if(Acc.PT_SMT_Manager_Email__c!='')
               {
                 gen.writeStringField('SMTManagerEmail_Id',Acc.PT_SMT_Manager_Email__c);
               }
               else
               {
                 gen.writeStringField('SMTManagerEmail_Id','');
               }
               if(Acc.PT_SMT_SPOC_Email_Id__c!='')
               {
                 gen.writeStringField('SMTExecEmail_Id',Acc.PT_SMT_SPOC_Email_Id__c);
               }
               else
               {
                 gen.writeStringField('SMTExecEmail_Id','');
               }
               gen.writeEndObject(); 
               if(Acc.PT_Lead_Stage__c!='')
               {
                 gen.writeStringField('Sf_State',Acc.PT_Lead_Stage__c);
               }
               else
               {
                 gen.writeStringField('Sf_State','');
               }
               if(Acc.Business_Info__c!=null)
               {
                 gen.writeBooleanField('Business_info',Acc.Business_Info__c);
               }
               else
               {
                 gen.writeBooleanField('Business_info',null);
               }
               if(Acc.Catalog_Received__c!=null)
               {
                 gen.writeBooleanField('Catalog_received',Acc.Catalog_Received__c);
               }
               else
               {
                 gen.writeBooleanField('Catalog_received',null);
               }
               if(Acc.Warehouse_Added__c!=null)
               {
                 gen.writeBooleanField('Warehouse_added',Acc.Warehouse_Added__c);
               }
               else
               {
                 gen.writeBooleanField('Warehouse_added',null);
               }
               if(Acc.Finance_Kyc__c!=null)
               {
                 gen.writeBooleanField('Finance_kyc',Acc.Finance_Kyc__c);
               }
               else
               {
                 gen.writeBooleanField('Finance_kyc',null);
               }
                 
             gen.writeEndObject();
      
          gen.writeFieldName('Address');
            gen.writeStartObject();
            if(Acc.PT_Company_Address__c!='')
            {
               gen.writeStringField('Address',Acc.PT_Company_Address__c);
            }
            else
            {
               gen.writeStringField('Address','');
            }
            if(Acc.PT_City__c!='')
            {
               gen.writeStringField('City',Acc.PT_City__c);
            }
            else
            {
              gen.writeStringField('City','');
            }
            if(Acc.State_CompanyAddress__c!='')
            {
               gen.writeStringField('State',Acc.State_CompanyAddress__c);
            }
            else
            {
               gen.writeStringField('State','');
            }
            if(Acc.PT_Pin_Code__c!='')
            {
               gen.writeStringField('Pin_code',Acc.PT_Pin_Code__c);
            }
            else
            {
              gen.writeStringField('Pin_code','');
            }
            gen.writeEndObject();
       
           gen.writeFieldName('Finance');
            gen.writeStartObject(); 
            if(Acc.PT_Beneficiary_Name_in_Bank__c!='')
            {
                gen.writeStringField('Beneficiary_name',Acc.PT_Beneficiary_Name_in_Bank__c);
            }
            else
            {
               gen.writeStringField('Beneficiary_name','');
            }
            if(Acc.PT_Account_No__c!='')
            {
               gen.writeStringField('Bank_account_no',Acc.PT_Account_No__c);
            }
            else
            {
               gen.writeStringField('Bank_account_no','');
            }
            if(Acc.PT_Bank_IFSC_Code__c!='')
            {
               gen.writeStringField('IFSC_code',Acc.PT_Bank_IFSC_Code__c);
            }
            else
            {
               gen.writeStringField('IFSC_code','');
            }
            if(Acc.PT_Bank_Name__c!='')
            {
                 gen.writeStringField('Bank_name',Acc.PT_Bank_Name__c);
            }
            else
            {
                gen.writeStringField('Bank_name','');
            }
            if(Acc.PT_Branch_Name__c!='')
            {
                 gen.writeStringField('Branch_name',Acc.PT_Branch_Name__c);
            }
            else
            {
                 gen.writeStringField('Branch_name','');
            }
            gen.writeEndObject();
          
          gen.writeFieldName('Kyc');
            gen.writeStartObject();
            if(Acc.PT_PAN__c!='')
            {
                 gen.writeStringField('PAN_Card_No',Acc.PT_PAN__c);
            }
            else
            {
                gen.writeStringField('PAN_Card_No',''); 
            }
            if(Acc.PT_VAT_TIN__c!='')
            {
                 gen.writeStringField('VAT_no',Acc.PT_VAT_TIN__c);
            }
            else
            {
               gen.writeStringField('VAT_no',''); 
            }
            gen.writeEndObject();
        
            gen.writeFieldName('Warehouse');
              gen.writeStartArray();
            
               gen.writeStartObject();
               if(Acc.Country_WarehouseAddress__c!='')
               {
                 gen.writeStringField('Address',Acc.Country_WarehouseAddress__c);
               }
               else
               {
                 gen.writeStringField('Address','');
               }
               if(Acc.PT_Warehouse_State__c!='')
               {
                 gen.writeStringField('State',Acc.PT_Warehouse_State__c);
               }
               else
               {
                 gen.writeStringField('State',''); 
               }
               if(Acc.PT_Warehouse_City__c!='')
               {
                 gen.writeStringField('City',Acc.PT_Warehouse_City__c);
               }
               else
               {
                 gen.writeStringField('City','');
               }
               if(Acc.PT_Pin_Code_Warehouse__c!='')
               {
                 gen.writeStringField('Pin_code',Acc.PT_Pin_Code_Warehouse__c);
               }
               else
               {
                 gen.writeStringField('Pin_code','');
               }
               gen.writeEndObject();
                
              gen.writeEndArray();
          gen.writeEndObject();
          String jsonString = gen.getAsString();
          System.debug('jsonString:'+jsonString);
          }
          
          }
          
      }
    }

its working fine but only non-null fields,suppose I have only two fields-1.Name and other is 2. Company name,if both fields have a value then it generates JSON file like-
{
"Name":"Ghulam",
"Company name":"Paytm"
}

but,if any field is null then it throughs error.
And I want to do if any field is null then also generate JSON file and dispaly the null value in JSON like below--
suppose "Company name" field is null then JSON will like-
{
"Name":"Ghulam",
"Company name":" "
}

I hope someone help me..
Thanks,
Ghulam
Hi Everyone,

I am new in salesforce development and I want to create a trigger on Task, when I create a task and Choose an Account, after choose an Account and now I choose a Contact then Contact lookup only display  contacts in lookup window that are related to that particular account rather than all contacts related to all accounts.

I need your help, please suggest me.

thanks,
Ghulam

 
Hi All,

Recently we are working on a POC on Social Customer Service where we implmented the functionality of creating a Case in salesforce from a Facebook post. This functionality is working fine and we have built this interface as per the standard guide provided by Slaesforce. But below is the new requirement that we need to fulfill along with the existing functionality.

If we tag any Social Account on our home page and write any comment , that should also create a case in salesforce.
Please help me out how to implement this new feature. Whether this is feasible or not. Any useful documents or links would be appreciated.

Please find attached the screenshots.
Thanks in advance.
Regards
Somnath
Hello, 

I'm trying to render a visualforce page based on a value passed from another record.  The Custom Button URL i'm using to open the VF page is:
/apex/AvailableInstructors?id={!Lesson__c.Id}&Date_c={!Lesson__c.Lesson_Date__c}


and rendering the records using the following:
 
<apex:pageblocktable value="{!schedules}" var="s" columns="13" rendered="{!Schedule_Availability__c.Date__c== DATEVALUE($CurrentPage.parameters.Date__c)}" >
The VF page is showing all records and not rendering it based on the date value passed.  Any help would be appreciated!

Thanks!
Hello, 

I'm trying to render a visualforce page based on a value passed from another record.  The Custom Button URL i'm using to open the VF page is:
/apex/AvailableInstructors?id={!Lesson__c.Id}&Date_c={!Lesson__c.Lesson_Date__c}


and rendering the records using the following:
 
<apex:pageblocktable value="{!schedules}" var="s" columns="13" rendered="{!Schedule_Availability__c.Date__c== DATEVALUE($CurrentPage.parameters.Date__c)}" >
The VF page is showing all records and not rendering it based on the date value passed.  Any help would be appreciated!

Thanks!