• sandeep reddy 37
  • NEWBIE
  • 169 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 3
    Likes Given
  • 54
    Questions
  • 130
    Replies
how to restrict user to take numberic input in visualforce page??

i am using  : :" <h1>Amount</h1><apex:input type="number" id="damount" value="{!damount}"    /> " 

it gives error "Expected input type 'text', got 'number' for String data type"
i like to update a perticular account number's balence in my bank application for that purpose i need to fetch 15 digit record id and i am unable to fetch it.. kindly help ..

Query
 Integer id  = [SELECT b1.Id FROM BankApplication__c WHERE b1.Account_Number__c =: accnum  ];

Error : 
Error: Compile Error: Didn't understand relationship 'b1' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 12 column 25
   
Hi All,
I have written trigger as below
Trigger TskTrigger on Task (after inert){
 List<Obj1__c> ls=[Select Id,Fld1__c,Fld2__c from Obj1__c];
//Some code
//Some code
if(Trigger.isInsert){

    List<Task> ts = new List <Task>();

        for(Task Tsk : trigger.new){
    
        Task c = new Task(Fld1__c=ls.Fld__c,Fld2__c=ls.Fld2__c);
}
But, I am getting error as " Initial term of field expression must be a concrete SObject: List<Obj1__c> at line  column "
What is wrong here?
Please help

Thanks in Advance
can any one please tell me how to get child records from parent object 
this the coad 


public class shopcart {
    public list<srinivasreddy__shopcart__c> scart{set;get;}
    public list<srinivasreddy__aproduct__c> apro{set;get;}
    public list<id> ids{set;get;}
    public shopcart(){
       apro=[select srinivasreddy__price__c,Name,(select Name,srinivasreddy__quantity__c,srinivasreddy__total__c from srinivasreddy__shopcart__r)  from srinivasreddy__aproduct__c];
       ids=new list<id>();
        scart=new list<srinivasreddy__shopcart__c>();
    }
    public void addproduct(){
        for(srinivasreddy__aproduct__c c:apro){
          srinivasreddy__shopcart__c sc=new srinivasreddy__shopcart__c();  
           sc.srinivasreddy__cartproduct__c=c.id;
            sc.Name=c.Name;
            scart.add(sc);
        }
        insert scart;
       
    }
}
}
what is schema.DataCategory and how to use schema.DataCategorygroups
and how to pass the objects and get the with child data catagery 
but I am passing list of object  i got a error  can any give me sugguation please
apex======>
List <String> objType = new List<String>();
objType.add('account');
objType.add('contact');
List<Schema.DescribeDataCategoryGroupResult> describeCategoryResult = 
   Schema.describeDataCategoryGroups(objType);
error====>
Line: 13, Column: 1
System.InvalidParameterValueException: Invalid sobject provided. The Schema.describeDataCategoryGroups() methods does not support the account sobject as a parameter. The sobject provided can not be associated with data category groups
I have batch apex class 
depending upon execute method all records assocated with email we can sent emails to this emails so my batch apex class is

global  class batchwithemails implements database.Batchable<sobject> 
{
    global list<string> toaddress=new list<string>();
    global database.Querylocator start(database.batchablecontext bc){
        string s='select id,name,industry,srinivasreddy__email__c from account limit 20';
        return database.getQueryLocator(s);
        
    }
    global void execute (database.BatchableContext bc,list<account> scope){
        for(account a:scope){
            a.srinivasreddy__Active__c='yes'; 
            toaddress.add(a.srinivasreddy__email__c);
            
        }
        update scope;
        
}
    global void finish (database.BatchableContext bc){
        messaging.reserveSingleEmailCapacity(20);
        messaging.SingleEmailMessage m=new messaging.SingleEmailMessage();
        string[] toaddres=new string[]{'toaddress'};
            m.setToAddresses(toaddress);
        m.setPlainTextBody('nothing to display');
        m.setSubject('first');
        Messaging.sendemail(new messaging.SingleEmailMessage[]{m});
    }

please help me 
can any one please tell me how to connect apex class to flow process give some navigtion inflow
I want to check deleted record assocated user id and undeleted record assocated user id must be equql other wise throws error
trigger undeletecheack on Account (after delete,after undelete) {
    set<id> personids=new set<id>();
    for(account c:trigger.old){
        if(trigger.isafter&&trigger.isdelete){
     user u=[select id,name from user where id=:userinfo.getUserId()]; 
       personids.add(u.id); 
    }
                              }
    for(account aa:trigger.new){
        if(trigger.isafter&&trigger.isundelete){
         user u2=[select id,name from user where id=:userinfo.getUserId()];
        list<user> lu=[select id,name from user where id=:personids];
        for(user i:lu){
            if(i.id==u2.id){
               
            } 
        }
        }
    }
}
advance thanks 
 
I have class with parameterised constractor
public class main{
public string head;
public string industry;
publuc list<account> acc;
public mail(string nam,string ind){
this.head=nam;
this.industry=ind;
acc=new list<account>();

}
public void dodml(){
account a=new account();
a.name=head;
a.industry=industry;
acc.add(a);
insert acc;
}

so please tell me 
how to call this class in vf page
 
using with sharing key word  but owd sharing rules =private 
how can we get record and is it accesble or not if yes or no how please tell me 
 
can any one tell me how to upload video in vf page which components are uses my video lenth more then 25 mb then what i do 
 
thanks 
sandeep
how to insert   field and also count after insert the value counting pageblock want dissable  below is the apex
++++++++++++++++++++++++++
public class counting {
public string apname{set;get;}
public string company{set;get;}
public integer view{set;get;}
public AggregateResult res{set;get;}
public list<account>acc{set;get;}
public counting(){
        acc=new list<account>();
    }
public void counting (){
account a=new account();
a.name=apname;
a.industry=company;
acc.add(a);
insert acc;
    acc.clear();
res=[select count(name)allnames from account];
view=(integer)res.get('allnames');
}
}
and below is vf page
==================
<apex:page controller="counting" >
    <apex:form>
    <apex:pageblock title="counting" id="no">
        <apex:pageBlockSection>
       name     :  <apex:inputText  value="{!apname}" /><br/>
       industry : <apex:inputText  value="{!company}"/>
            </apex:pageBlockSection>
    </apex:pageblock >
        <apex:commandButton value="view" action="{!counting}"  />
        <apex:pageblock title="view" id="a">
        total views is:    <apex:outputText value="{!view}" />
    </apex:pageblock>

        </apex:form>
</apex:page>
if know please give me answer

 
i write programe about transforing data from json to class the code is 
public class jsonclass {
    public string result{set;get;}
    public jsonclass(){
              string jso ='{"name":"suriprakesh","age":20,"salary":20000}';
    map<string,list<string>> m = (map<string,list<string>>)JSON.deserializeuntyped(jso);
        }
    
    }
       its getting run time error that is just tell me please  
i want delete all account records between the 1st to 30th right 
how will performs we
public class transforms {
    public account acc;
    public date start;
    public date  end;
    public transforms(){
        start=new date();
        end=new date();
        end.date.newInstance(1,05,2016);
        start.date.newInstance(25,04,2016);
        acc=new account();
        database.getDeleted(acc, start, end);        
    }
}
this is my program how to fetch all the myphone,myname fields please tell me
   public class dynamicallsoql {
    public string myname{set;get;}
    public stringmy phone {set;get;}
    public sobject obj {set;get;}
    public list<sobject> sobj{set;get;}
    public dynamicallsoql(){
        database.query('select'myname,myphone 'from' obj);
    }

}
}
i need hard delete all account records  with out cheaking  recyclebin will select all and delete it
how it wii possoble which method will uses
 
when i select particular object that object allfields need to display how is it possiple please tell me 

public class displaylistofallfields {
    public map<string,schema.SObjectType> obj{set;get;}
    public set<string> lobj{set;get;}
    public list<selectoption> pick{set;get;}
    public string selected{set;get;}  
    public list<selectoption> outfields{set;get;}
    public set<string> fields{set;get;}
    public displaylistofallfields(){
        outfields=new list<selectoption>();
        obj=schema.getGlobalDescribe();
        lobj=new set<string>();
        fields=new set<string>();
      lobj=obj.keySet();
        for(string s:lobj){
            selectoption op=new selectoption(s,s);
            pick.add(op);
        }
        
    }
    public void display(){
     list<schema.SObjectfield>   allfields =pick.getlabel(selected);
            for(string f :allfields){
            selectoption p=new selectoption(f.getlabel(),f.getlabel());
            outfields.add(p);
          }
 }
}
just please tell me
 
i have doubght about flow it s not getting out put just help me and how can we invoke class in to flow please tell me 
i dont know about over come the bulkfy operation for sosl plese tell me with progrme
i need get error if  inserting a records  if dml is fails  shows error 
how to do  please tell me let you know


public class batchapexerror implements database.Batchable<sobject>,database.stateful {
    public string errors[] =new new string[]{'jnkjdnksdj','hfhh'};
    public database.QueryLocator start(database.BatchableContext be){
        return database.getQueryLocator('select id,name,firstname,lastname from account ');
       }
    public void execute(database.BatchableContext bc,list<sobject> acc){
        account a=new account();
        for(account a1:a){
               try{
                   if(a.AnnualRevenue==50000){
                a.name='prakesh';
                a.industry='banking';
                insert a;
                   }
               }catch(exception e){
                       errors.add(e.getmessage());
                   }
                   
            } 
            
        }
    public void finish(database.BatchableContext bc){
        
    }
   }

i need to fetch the objects  by using selected list it will shows related child objects 
how we do 
public class schemaprograming {
    public list<selectoption> cobj {set;get;}
    public  string name1{set;get;}
    public list<string> field{set;get;}
    public list<selectoption> opt{set;get;}
    public sobject myobject{set;get;}
    public schemaprograming(){
        field=new list<string>();
        
        opt=new list<selectoption>();
        map<string,schema.SObjectType> myobj=schema.getGlobalDescribe();
        set<string> keys=myobj.keySet();
        list<string> order =new list<string>();
        order.addAll(keys);
        order.sort();
        for(string a:order){
            selectoption s =new selectoption(a,a);
            opt.add(s);
               
                    
            Schema.DescribeSObjectResult child= myobject.sobjecttype.getdescribe();
            list<schema.ChildRelationship> R = child.getchildrelationships();
            for(schema.ChildRelationship p :R){
                
                cobj=new list<selectoption>();
                string name1 =''+p.getChildsobject();
                selectoption c1 =new selectoption(name1,name1);
                cobj.add(c1);
            }
                }
            } 
        }



------------------vf page -----------------------------------------------
<apex:page controller="schemaprograming" readOnly="true">
    <apex:form >
       <apex:pageMessage severity="champakmala"  />
        <apex:pageBlock title="standard and custem objects">
            <apex:pageBlockSection >
                <apex:selectList value="{!myobject}" size="1" >
                    <apex:actionSupport event="onchang" reRender="cod" />
            <apex:outputLabel value="objects"/>&nbsp;
            <apex:selectOptions value="{!opt}"/>
            </apex:selectList>
                </apex:pageBlockSection>
                      </apex:pageBlock>
                    <apex:pageBlock title="child objects" id="cod">
                    <apex:selectList size="6" value="{!field}">
                        <apex:selectOptions value="{!cobj}"/>
                    </apex:selectList>
                    </apex:pageBlock>

    
    </apex:form>
</apex:page>
how can we do batch apex updating lookupfield
program is exeuted but requir ment is not met
do this for me
global class batchapexforlookup implements database.Batchable<sobject> {
    list<custmer__c> c;
    global void batchapexforlookup(){
        c=new list<custmer__c>();
    }
    global database.Querylocator start(database.batchablecontext bc){
        return database.getQueryLocator('select area__c,digit__c,newcustmer__r.Name from application__c');
    }
    global void execute(database.batchablecontext bc,list<application__c> app){
        for(application__c a:app){
            a.newcustmer__c='2015-0037';
                    }
        update app;
    }
    global void finish(database.BatchableContext bc){
        
    }
this is the code bellow
<apex:page sidebar="false" showHeader="false" tabStyle="Account"  standardController="Account" recordSetVar="acc">
                                 <script src="https://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
                        <script type='text/javascript'>
                       
                           var j$=jQuery.noConflict();
                            var names =['ram','sham','praveen','prashant','sham','ramesh'];
                           j$(document).ready(function(){
                               j$('[Id$=abcd]').autocomplete({
                                   source : names
                                   });
                               });
                           
                       
                            </script>
   
     
     <script type="text/javascript">
    var m =jQuery.noConflict();
      m(document).ready(function(){
        m("[Id$=srikanth]").hide();
        j$('[Id$=p]').change(function(){
        var name=m('[Id$=p]').val();
        
        if(name='on'){
           m('[Id$=srikanth]').show();
            }
           
            });
        });
              
              
         
    </script>
    <apex:form >
        <div>
        <apex:tabPanel id="first" styleClass="one">
            <apex:tab title="about" label="aboutus" />
            <apex:tab title="custmercenter" label="custmercenter" />
            <apex:tab title="csr" label="csr"/>
            <apex:tab title="personal" label="personal" styleClass="two" >
            <apex:image value="{!$Resource.hdfc}" height="50px" width="180px"  />
                <hi style="font-size:20px; color:red; " > bank aapiki muttai mein</hi>
                <apex:tabPanel >
                    <apex:tab label="home"/>
                        
                    <apex:tab label="products"/>
                    <apex:tab label="making payments"/>
                    <apex:tab label="waytobank"/>
                    <apex:tab label="smatrbye"></apex:tab>
                    <apex:tab label="cuatmercare"/>
                    <apex:tab label="applynow">
                       <apex:pageBlock title="apply for lonss">
                           <apex:pageBlockTable value="{!acc}" var="ac"></apex:pageBlockTable>
                           <apex:outputLabel value="firstname" ></apex:outputLabel>  
                           
                           <apex:inputText label="firstname" maxlength="50" id="abcd" value="{!ac.name}" /><br/><br/>

                          <apex:inputText label="lastname"   maxlength="20" id="abc" value="{!ac.SLASerialNumber__c}" />
                               SHOW:<apex:inputCheckbox id="p" />
                                </apex:pageBlock>
                    
        <apex:pageBlock title="personal details" id="srikanth">
            <apex:pageBlockTable value="{!acc}" var="ca"></apex:pageBlockTable>
            <apex:outputLabel value="phone no" ></apex:outputLabel>&nbsp;&nbsp;
        <apex:inputText id="a"  value="{!ca.Phone}" /><br/><br/>
            <apex:outputLabel value="password"></apex:outputLabel>&nbsp;&nbsp;
            <apex:inputSecret id="b"  value="{!ca.pass__c}"  />
        </apex:pageBlock>
                        <apex:commandButton value="save" action="{!URL(!$action.Account.save;)}" />
                         </apex:tab>
                     <apex:tab label="find your nearest"/>
                </apex:tabPanel>
            </apex:tab>
            <apex:tab title="premier" label="premier" />
            <apex:tab label="NRi"/>
            <apex:tab label="sme"/>
            <apex:tab label="holesale"/>
            <apex:tab label="agri"/>
         </apex:tabPanel>
        </div>
        <style>
            .one{
            background-color:skyblue;
            }
            .two{
            backgroung-color:yellow;
            }
        </style>
       
    </apex:form>
   
</apex:page>
please infofrm me urgently
 
what is compact lay out tell me with example pleaseeeeee
I have a variable I am trying to pass to the controller, but it is not working. According to several posts I've seen it should work. Here's my code:

VF:
<apex:actionFunction action="{!clickedRow}" name="call_clickedRow">
     <apex:param value="" assignTo="{!selectedRow}"/>
</apex:actionFunction>

<apex:repeat value="{!object1}" var="var1">
     <tr onclick="call_clickedRow({!var1.Name}); alert({!selectedRow});">
          //.................................................
          //.................................................
     </tr>
<apex:repeat>

Controller:
public String selectedRow{ get; set; }

public PageReference clickedRow(){
        return null;
}

I am however, getting a XmlHTTPSynchronous error that when expanded says that it is related to the onclick event shown above. I've tried several different methods of sending variables to the controller, but none have worked so far. I have also tried putting async=true in many places, but maybe not the right one. Any and all help would be appreciated. Thanks in advance.
Hi All,
I have written a trigger on Order.
I am giving errors in two scenarios. I have one custom field Blocked__c in account. If I have blocked__c = Y, I dont want to create order.
This condition is not working properly.
This is my code. Please tell me where is bug
trigger orderTrigger on Order (before insert) {

List<Order> ordLs = [Select Id, F1__c,Status,AccountId,Account.Blocked__c from Order where createdDate=today ];  

for (Order ordNew : Trigger.new)
  {      
    for(Order oa: ordLs)
        {         
               if(oa.AccountId == ordNew.AccountId && oa.F1__c == ordNew.F1__c && oa.status == 'confirmed')         
                  {              
                    ordNew.AccountId.addError('Some messge');        
                  } 
               if(oa.Account.Blocked__c=='Y') {
                   ordNew.AccountId.addError('Blocked'); 
               } 
         }
        
  }

}

Please help me.
Line Number 13 is not working properly. Please suggest me changes.
Thanks in Advance
Dear Experts,

I'm new bee to APEX (and programing), can you pls explain me to understand below code (bold Highlighted):
- encriptedFieldsMap.put, What Map gets if inner class constructor calls?

Request: I'm new to programming, kindly articulate your answer in a lay man language.. thanks in advance.

Thanks,
Srujan

public class EncriptFieldValueMover {
   
    public Map<String,EncriptFieldValueMover.EncriptedField> encriptedFieldsMap {get;private set;}
    public String fieldApiName = 'FieldAPI';
    public Account encFieldCS;
   
    public EncriptFieldValueMover(){
        encriptedFieldsMap = new Map<String,EncriptFieldValueMover.EncriptedField>();
        encriptedFieldsMap.put(fieldApiName,new EncriptFieldValueMover.EncriptedField(fieldApiName,encFieldCS));
    }
 
    public class EncriptedField{
        private String fieldAPIName;
        private String elatedEncriptedField;
        public account encFieldCS {get; private set;}
       
        public EncriptedField(String fieldAPIName, Account encFieldCS){
            this.fieldAPIName = fieldAPIName;
            this.encFieldCS = encFieldCS;
        }
       
        public String getFieldAPIName(){
            return fieldAPIName;
        }
       
        public String getRelatedEncriptedField(){
            return encFieldCS.Name;
        }
    }
}
Error : Invalid Type : opps__c in Apex code
Here opps is a custom object, i replace this one with standard , but also i get same error invalid type. 
I fetch the data from 3 objects where the name field value is given by me. If i delete the 3rd object i got the result. Why Its not work on 3 objects. 
Plz Help me guys to overcome this problem.

Visual force Page :


<apex:page controller="apmult" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title=" Enter the Value">
                <apex:outputText value=" Enter Name "></apex:outputText>
                <apex:inputText value="{!aname}"/>
                <apex:commandButton value=" SUBMIT " action="{!save}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title=" Display Account Records ...{!lac}">
                <apex:pageBlockTable value="{!arecs}" var="item">
                <apex:column value="{!item.id}"/>
                <apex:column value="{!item.name}"/>
                <apex:column value="{!item.phone}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title=" Display Lead Records ...{!llc}">
                <apex:pageBlockTable value="{!lrecs}" var="item">
                <apex:column value="{!item.id}"/>
                <apex:column value="{!item.name}"/>
                <apex:column value="{!item.phone}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title=" Display Oops Records ...{!loc}">
                <apex:pageBlockTable value="{!orecs}" var="item">
                <apex:column value="{!item.id}"/>
                <apex:column value="{!item.name}"/>
                <apex:column value="{!item.phone}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
          </apex:pageBlock>
       </apex:form>
</apex:page>

APEX CODE :

public class apmult {
    public string aname{set;get;}
    public list<account> arecs{set;get;}
    public list<lead> lrecs{set;get;}
    public list<opps__c> orecs{set;get;}
    
    public integer lac{set;get;}
    public integer llc{set;get;}
    public integer loc{set;get;}
    
    public void save(){
        arecs=[select id,name,phone from account where name=:aname];
        
        lac=arecs.size();
        
        lrecs=[select id,name,phone from lead where name=:aname];
        
        llc=lrecs.size();
        
        orecs=[select id,name,phone from account where name=:aname];
        
        loc=orecs.size();
    }

}
HI

I have a trigger written that updates a field on the account page from the contract page but only for certain products.  I have this written as a list (in bold) but it is not picking up these products.  I have been told to change to a set but I am not familar with sets copy of trigger below can anyone help with this?

Trigger updateESPWorryDate on Contract (after insert, after update)
{
List<Contract> CL=trigger.new; 
List<Id> aid=new List<Id>(); 
for(Contract c: CL) 

aId.add(c.AccountId); 


list<Account> AL=new List<Account>(); 

for(Account a: [select Id from Account where Id in :aId]) 

List<Contract> ICL=[select Status, Sub_End_Date__c from Contract where AccountId=: a.Id]; 
String max='1900-01-01';
for(Contract c: ICL) 

List<String> productCodeList = new List<String>{'ESP-E-R','ESP-B-R', 'ESP-B-I', 'ESP-P-R', 'ESP-P-I', 'ESP-E-I'};
{
if(c.Status=='Activated' && c.Sub_End_Date__c !=null) 
if(Date.valueOf(max)<c.Sub_End_Date__c) 
max=String.valueOf(c.Sub_End_Date__c); 
}
if(max!='1900-01-01')
a.ESP_Worry_Date__c=Date.valueOf(max); 
AL.add(a); 
}
Set<Account> accountData = new Set<Account>(AL);
AL=new List<Account>(accountData);
if(AL.size()>0)
   update AL;
}
}
how to restrict user to take numberic input in visualforce page??

i am using  : :" <h1>Amount</h1><apex:input type="number" id="damount" value="{!damount}"    /> " 

it gives error "Expected input type 'text', got 'number' for String data type"
i like to update a perticular account number's balence in my bank application for that purpose i need to fetch 15 digit record id and i am unable to fetch it.. kindly help ..

Query
 Integer id  = [SELECT b1.Id FROM BankApplication__c WHERE b1.Account_Number__c =: accnum  ];

Error : 
Error: Compile Error: Didn't understand relationship 'b1' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 12 column 25
   
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, I have one question,

whithout using data loder how to insert 60000 records into salesfore.

Please let me if there have any way to overcome this

Thanks in advance
Hi, I have some confussion witth feature annotation and batch class,
what is the exact difference between feature annotation and batch class? which case we would prefer feature and which case we would prefer batch class? Please give me one real time scenario for where we can use exactly,

Thanks in advance
Hi,

My test class is not covering custom object fileds,see the below code.

in test class i am calling  a method  by passing list of ids,
RequestHandler.createProces(listof ids);

in actual class i'm validating contact ids and if that contact id is not there in another object i'm inserting that id along with other values,code is below:

 List<Request__c> lsRequest;
       Request__c oRequest = new Request__c();     
        List<Request__c> lWr = new List<Request__c>();
for(....)
{
 lsRequest =[SELECT Active__c ,Member__c,attempt_1__C,attempt_2__C,attempt_3__C FROM  Request__c WHERE
                               member__c =: c.Id and Active__c=true and (Attempt_1 __c = true OR Attempt_1 __c = true OR Attempt_1 __c = true)];
           
            oRequest =  (!lsRequest.isEmpty() && lsWaiver_Request.size()>0) ?lsWaiver_Request[0] : null;
          
      //if empty i'm inserting values 
            if(lsRequest.isEmpty())
            {   
              
              //test class is not covering these fields
                oRequest.Member__c = c.id;             
                oRequest.Attempt_1__c = true;
              //few other fileds
}
 
Thanks

 
I want to add opportunity Amount to related account AnnualRevenue automatically and i want to remove the Opportunity amount from Account AnnualRevenue when opportunity gets deleted. And I want to update Account AnnualRevenue with updated opportunity amount.To achieve this i am getting following error "Invalid foreign key relationship: Account.Opportunities" could any one please resove this issue.I hope I will get correct code.

This is my trigger:
trigger addoppAmounttoAcct on Opportunity (After insert, After update) {
    public decimal amount=0;
    Map<id,integer> oppmap=new Map<id,integer>();
    List<Account> acc=new List<Account>();
    List<Account> a=[SELECT Id,Name,AnnualRevenue,(SELECT Id,Name, Amount FROM Opportunities) FROM Account];
    if(trigger.isInsert){
    set<Id> oppids=trigger.newMap.keySet();
    Map<Id,Integer> accmap=new Map<Id,Integer>();
    //List<Account> a=[SELECT Id,Name,AnnualRevenue,(SELECT Id,Name, Amount FROM Opportunities) FROM Account];
    List<Opportunity> opplist=[SELECT Id, Name,Amount,Opportunity.AccountId FROM Opportunity WHERE Id IN:oppids];
    //List<Account> acc=new List<Account>();
    for(Account ac:a){
    for(Opportunity o:opplist){
        if(o.AccountId==ac.id){
          ac.AnnualRevenue=ac.AnnualRevenue+o.Amount;
            acc.add(ac);
       }else{
           oppmap.put(o.Id, 1); 
        }
     }
  }
    update acc;
        }
 if(trigger.isUpdate){
   set<Id>updateids=trigger.newMap.keySet();
     List<Opportunity> opplistids=[SELECT Id, Name, Opportunity.AccountId,Opportunity.Account.AnnualRevenue, Amount FROM Opportunity WHERE Id IN:updateids];
        for(Opportunity upopp:opplistids){
            for(Account aid:a){
            if(upopp.AccountId==aid.Id){
                amount=upopp.Amount;
                aid.AnnualRevenue=aid.AnnualRevenue-aid.Opportunities.Amount;// here i am getting error like "Invalid foreign key relationship: Account.Opportunities"
                amount=aid.AnnualRevenue;
              aid.AnnualRevenue=amount+upopp.Amount;
                acc.add(aid); 
                }
            } 
        }
        update acc;
    }

Here my intension is to add opportunity amount to account Annual revenue after inserting the opportunity. And update the Annual revenue with updated  opportunity Amount. when i try to inserting opportunity there is no issue. When i try to perform update opportunity amount the previous amount and updated amount both will be added to the account Annualrevenue but my intension is to update only current updated Amount and remove previous amount from the Account AnnualRevenue.
Example:
i have one Account i.e' account1' if Icreate opportunity i.e 'account1opportunity' for this account with amount as 2000 the account1 Annual revenue is updated as 2000 this is fine, but if update account1opportunity with 4000 the related account1 AnnualRevenue is updated with previous amount i.e, 2000 plus updated Amount 4000 i.e  Annual revenue will be updated as 6000 according to my code. But I want to remove previous 2000 amount and update AnnualRevenue with current updated Amount i.e Annual revenue should be 4000.
Hi All,
I have written trigger as below
Trigger TskTrigger on Task (after inert){
 List<Obj1__c> ls=[Select Id,Fld1__c,Fld2__c from Obj1__c];
//Some code
//Some code
if(Trigger.isInsert){

    List<Task> ts = new List <Task>();

        for(Task Tsk : trigger.new){
    
        Task c = new Task(Fld1__c=ls.Fld__c,Fld2__c=ls.Fld2__c);
}
But, I am getting error as " Initial term of field expression must be a concrete SObject: List<Obj1__c> at line  column "
What is wrong here?
Please help

Thanks in Advance
hi.
 I have one custom object  properties__c , in the detail page of a record,  I have a custom button(Find Properties )  which is going to filter the properties , based on the selected properties  I want to send an email to the customer for that i have created another custom button while clicking on button   automatically  the new window should get opened with email properties how to achieve this functionality & automatically the data should get mapped in the  email template which i want to send. & also email should be entered  manually writing the   address in To,. 
Hi Experts,

i have two Picklist .Two pick list are TO and casereason.
whenever user a selected a vlaue with (Com Apg )from To Picklist then (PO Bokeed) with value dispaly in Casereason picklist .
How to we can achive in visualforce page.below i have attached my screen shatUser-added image

Thanks,
VIswa.
The problem:
 
I'm not able to autofill the program look-up field that is built on the appointments (custom-object) with the corresponding program (custom-object) record.
 
Background:
 
X is a medical clinic that runs weight loss programs for obesity patients. X offers three types of programs; VLCD (Very Low Calorie Diet), Stepwise, Maintenance. Each of the programs length is 6 month.
 
Patients normally schedule appointments either weekly, bi-monthly, or monthly for six month period.
 
Objective:
 
My goal to write a code that tie every appointment record to the unique correspondent program for the patient. A program may have zero or many appointments. (This is what I'm trying to resolve here)
 
What I've built:
 
I have built three objects:
 
1. Patients (Accounts; standard-object)
 
2.Programs (Custom object; each record represents a program that is unique for the patient)
* There is a master-detail relationship between the patients object and program. Patients may have zero or many programs.
 
3.Appointments: (Custom object; each record represents an appointment that the patient has made).
* I've built a look-up relationship between the programs object and the appointments object. I want to tie every appointment to a unique program. A program may have zero or many appointments. (This is what I'm trying to resolve here)
 
I've tried these two methods (Process builder and workflow automation rules, and they both failed):
*I was told by SF support that this only can be done through APEX code since its "objects are falling under Dynamic Relationship"

 
I tried to do it through creating workflow automation rules and process builder by setting this condition and immidate actions below. When formula evaluates to true:
 
AND(Program__r.Program_start_date__c < appointments__r.
scheduled_time__c,
appointments__r.scheduled_time__c < Program__r.Program_end_date__c)
 
Fire Workflow action -- Update look-up field: Program name: appointemnts__r.patient__r.Program__c
 
Results: Appointments_r.Program__c remained NULL.

*I was told by SF support that this only can be done through APEX code since its "objects are falling under Dynamic Relationship"

Can someone please help me automate this look-up field update through APEX ? Clear guidance would be appericated since I have zero experince with APEX coding.


P.S:

All the fields (scheduled date, programs..etc) metioned above are autofiled either through APIs calls from our other internal systems or by being calculated fileds. 
Hi, Can anyone help me out with this,
User-added image
This is from a custom object " Quotation", The look up field " Main Driver" is a look up to Personal account object. The below fields are as well exists in the personal account. I need whatever value would be choosen in the main driver, automatically the below values will get pop up on below fields. I need to write a trigger for this ( I cant use formula field, as its depends upon another criteria field, so somtimes the user need to enter values manually in these fields , Process builder also doesnt worked).
I tried to write a trigger, but its not working , showing issue as " Error: Compile Error: IN operator must be used with an iterable expression at line 12 column 104 " Can anyone plz rectify my trigger to make it work. Thnx .( I just have taken two fields below for test)


trigger MainDriverRelatedFields on Quotation__c (before insert,before update) {

Quotation__c newQuote=new Quotation__c();
 
for(Quotation__c obj : Trigger.new){
newQuote=obj ;
    }
    List<Account> Acc= [SELECT id,Age__c, Acccidents_in_the_last_12_mnths__c FROM Account WHERE Id IN: newQuote.Main_Driver__r];
     if(newQuote.Main_Driver__c!=null) {
            newQuote.AgeMainD__c=Acc.Age__c;

            newQuote.Accidents_in_the_last_12_mnthsMainD__c= Acc.Acccidents_in_the_last_12_mnths__c;

        }
}




 
Hi Team,

We have created Two batch classes using different objects(Account and Opportunity) for updating the Teammembrs which are working fine.But my problem is i want to include onebatch class instead of two batch class.Can any one please help on this.

Thanks

Hi,

 

I have a custom controller called: MyController, I did 

Error: Unknown constructor 'MyController.MyController(ApexPages.StandardSetController controller)'.

 

On my controller code I have the following implementation of a simple constructor:

 

public class MyController {
    public Plan_Table__c table;
    public List <Table_Account__c> table_acc;
    public MyController() {
        table = null;
        table_acc = null;
    }

 

 

// some get and set APIs ....

...

...

...

}

 

Why do I keep getting this error when saving my tag file:

<apex:page standardStylesheets="false" sidebar="false" StandardController="Table_Account__c" Extensions="MyController" tabStyle="Account" recordSetVar="acc">

 

...

...

...

 

 

Thanks,

Guy

Hi All,
I am creating a task using batch apex. Through batch apex I am inserting 50% data into Task (From Custom object1).
Remaining data I have in Custom Object2.
I want to get that data by using Trigger
I want to compare Account Id of Task with Custom Object 2(I have Lookup to Account in Custom Object2).
Can I do this by using Trigger?
Now, on which object I have to trigger and how syntax should be?

Thanks in Advance
Hello,

---------TRIGGER----------

trigger UpdateReportName on ActivityPlanningAndReport__c (before insert) {
     Map<Id,User> ownerMap;
     Set<Id> oppOwnerIds = new Set<Id>();
     String nameOfOwner;
     for(ActivityPlanningAndReport__c p : trigger.new)
    {
        oppOwnerIds.add(p.OwnerId);
    }
     ownerMap = new Map<Id,User>([SELECT Id, Name FROM User WHERE Id IN :oppOwnerIds]);
     for(ActivityPlanningAndReport__c p : trigger.new)
     {
          nameOfOwner = ownerMap.get(p.OwnerId).Name;
        if(p.Name!=null)
        {
            p.Name = p.Country_txt__c+'_'+ p.Display_Engagement_Date__c+'_'+nameOfOwner;
     }
     }   
   }
Can anybody tell how to read the barcode from the image and display the product information details regarding the barcode image.

Using EAN 128 image format. It should accept only EAN 128 image format. 

Thanks in advance.