• Gauravendra
  • NEWBIE
  • 210 Points
  • Member since 2018

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 27
    Replies
I have a requirement for PAN Number field should include 5 text, 4 Number and 1 Text characters should include for that i wrote validation rule.
Rule passed succesfully, but record is not saving in any formates. Can you please let me know the my mistake.

NOT(AND( 
(REGEX( PAN_Number__c , "[A-Z][a-z]{5}[0-9]{4}[A-Z][a-z]{1}") ), 
LEN( PAN_Number__c) <> 10))

User-added image
Thanks in Advance!
SyamReddy.
Hi Guys,

I have a requirement ..i  need to create a visualforce page which will display all account names in custom picklist.
Please help me on this.

Thanks in Advance.
Smitha
Hi, 
I want to develop a page which has two radio button as options : radio1  and radio2 . on click of radio1 a form of account should be avaialble and on click of radio2 a form of contact should be available. 

I have my code but on click of both radio button it is redirecting to contact page only. can u help me to solve my issue

<apex:page controller="AccController">
 <apex:form >
 <apex:pageBlock id="pgblk"> 
 <apex:selectRadio id="radioid" layout="pageDirection">
 <apex:selectOption  itemLabel="radio1" itemValue="1"></apex:selectOption>
 <apex:actionSupport event="onclick" action="{!AccForm}">
 </apex:actionSupport>
 
 <apex:selectOption itemLabel="radio2" itemValue="2"></apex:selectOption>
 <apex:actionSupport event="onclick" action="{!ContForm}">
 </apex:actionSupport>
 </apex:selectRadio>
 
 </apex:pageBlock>
 </apex:form>
</apex:page>

Here is my controller
public class AccController 
{
 public PageReference AccForm()
 {
 PageReference Page = new PageReference('/apex/CreateAcc');
 Page.setRedirect(true);
 return Page;
 }
 
 public PageReference ContForm()
 {
 PageReference Page = new PageReference('/apex/CreateContact');
 Page.setRedirect(true);
 return Page;
 }
}
while saving 11th  record it should show an error while saving that limit had exceeded

I am trying to display a selectList in a visualforce page using a custom controller i built.

I get an "List has no rows for assignment to SObject" error when trying to preview the page, but running the query in the developer console, returns the rows.

here is my page:
 

<apex:page Controller="BpmIcountPayment">
    <apex:param name="first_name" value="Account.FirstName"/>
    <apex:param name="last_name" value="Account.LastName"/>
    <apex:param name="id" value="Account.idnumber__c"/>
    <apex:param name="address" value="Account.Address"/>
    <apex:form >
        <apex:selectList value="{!productsTitle}" multiselect="false">
            <apex:selectOptions value="{!ProductsLov}"></apex:selectOptions>
        </apex:selectList>
        </apex:form>
</apex:page>

and my controller:

public class BpmIcountPayment{

    private final Account account;

    public String productsTitle {
      get { return 'products for sale'; }
      set;
    }
 
    public BpmIcountPayment() {
        account = [SELECT Id, Name, Site FROM Account
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getAccount() {
        return account;
    }

    public List<SelectOption> getProductsLov() {
        List<SelectOption> products = new List<SelectOption>();
        List<Product2> productsList = [SELECT Id, Name, Family 
                                      FROM Product2 
                                      WHERE (Family = 'ShopProduct') 
                                      OR (Family = 'CourseParent') 
                                      OR (Family = 'SFCourseProgram')];

        system.debug(productsList);
        for (Product2 currProduct : productsList) {
            products.add(new SelectOption(currProduct.Id, currProduct.Name));
        }

        return products;
    }
}
Am, using the concept of Wrapper class. I want to delete recently created contact record from pageBlockTable.
I am facing Unknown property 'SingleRecordDelete.ContactWrp.id' Error
Here is What I did--

VF page

<apex:page controller="SingleRecordDelete">
  <apex:form >
     <apex:pageBlock title="Contacts">
          <apex:pageBlockSection title="New Contact" columns="2" id="fresh">
              <apex:inputText label="FirstName" value="{!fname}" />
              <apex:inputText label="LastName" value="{!lname}"/>
              <apex:commandButton action="{!save}" value="Save" reRender="lab,fresh"/>
          </apex:pageBlockSection> 
         
          <apex:pageBlockSection title="ContactList" id="lab">
              <apex:pageBlockTable value="{!crp}" var="cy" id="update">
                  <apex:column headerValue="FirstName">
                      <apex:outputLabel value="{!cy.cn.firstname}"/>
                  </apex:column>
                  <apex:column headerValue="LastName">
                      <apex:outputLabel value="{!cy.cn.lastname}"/>
                  </apex:column>
                  <apex:column >
                         <apex:commandLink value="Delete" action="{!doDelete}" style="color:Red" reRender="lab">
                             <apex:param name="did" value="{!cy.id}" assignTo="{!did}"/>
                         </apex:commandLink>
                  </apex:column>
                  
              </apex:pageBlockTable>
                  
          </apex:pageBlockSection> 
               
     </apex:pageBlock>
  </apex:form>
</apex:page>

ApexClass
public with sharing class SingleRecordDelete {

    public String fname {get;set;}
    public String lname {get;set;}
    public String did {get;set;}
    
    public List<ContactWrp> crp {get;set;}
    
    public SingleRecordDelete(){
        crp = new List<ContactWrp>();
        
    }
    
    public void save(){
      Contact c = new Contact();
      c.firstname = fname;
      c.lastname = lname;
      insert c;
      crp.add(new ContactWrp(c));
      fname='';
      lname='';
    }
    
    public void doDelete()
    {
        List<Contact> contactToBeDelete = new List<Contact>();
        Contact cod = [select id from Contact where id =: did];
        contactToBeDelete.add(cod);
        delete contactToBeDelete;
    }
    
     public class ContactWrp{
    
      public Contact cn {get;set;}
      
        public ContactWrp(Contact cs){
            this.cn = cs;                   
        }
    }
}
Hello,

I am trying to schedule a class to run at a specific time everyday. I get the error
'Method does not exist or incorrect signature: void schedule(String, String, WarehouseCalloutService) from the type System'
when I save the following in dev console: 

global class WarehouseSyncSchedule implements Schedulable{
  // implement scheduled code here
    global void execute(SchedulableContext ctx) {
        WarehouseCalloutService w = new WarehouseCalloutService();
        String sch = '0 0 1 * * ?';
        String SyncWithWarehouse = System.schedule('Warehouse Callout Service', sch, w);
    }
}

Looking for help with this error.
Hi Team,

How can we attach the event to a new opportunity?

Regards
Lakshmi
I have a requirement for PAN Number field should include 5 text, 4 Number and 1 Text characters should include for that i wrote validation rule.
Rule passed succesfully, but record is not saving in any formates. Can you please let me know the my mistake.

NOT(AND( 
(REGEX( PAN_Number__c , "[A-Z][a-z]{5}[0-9]{4}[A-Z][a-z]{1}") ), 
LEN( PAN_Number__c) <> 10))

User-added image
Thanks in Advance!
SyamReddy.
global class MasterPaymentSchedules implements Database.Batchable<sobject>{

  
    global Database.querylocator start(Database.BatchableContext BC){
        String s = String.valueOf(system.today());
        
 
           String Query='select opportunity__c,IsDeleted, Date__c,Payment_Received_Date__c,Open_Principal__c,Total_Pay__c,InterestPmt__c,PrincipalPmt__c,PrincipalPmt_As_Per_Books__c,TDS__c,Net_Payment__c,Clearance__c,ClosingPrincipalBal_As_Per_Books__c,ClosingPrincipalBal__c,Balance_Days_for_NPA__c,Delinquent_Days__c from Payment_Schedules__c WHERE (CreatedDate = TODAY OR LastModifiedDate = TODAY)';
    //QueryResult qr = connection.queryAll(Query);
        return Database.getQueryLocator(Query);
    }
    
    global void execute(Database.BatchableContext BC,List<Payment_Schedules__c> paysch){
         List<Master_Payment_Schedules__c> LstNewMPS = new List<Master_Payment_Schedules__c>();
         set<id> SETOPP=NEW set<id>();
      set<id> setoppid=new set<id>();
        map<id,id> mapaccount=new map<id,id>();
        FOR(Payment_Schedules__c ps2 : paysch){
            Opportunity opp=[select id,accountid from opportunity where id=:ps2.Opportunity__c];
            setopp.add(opp.accountid);
            setoppid.add(opp.id);
            mapaccount.put(opp.id, opp.AccountId);
        }
         List<Master_Payment_Schedules__c> LstMPS = [select id,Open_Principal__c,Total_Pay__c,InterestPmt__c,Clearance__c ,
                                                    PrincipalPmt__c,PrincipalPmt_As_Per_Books__c,TDS__c,Net_Payment__c,ClosingPrincipalBal__c,
                                                    ClosingPrincipalBal_As_Per_Books__c,Date__c,Payment_Received_Date__c,Balance_Days_for_NPA__c,
                                                    Delinquent_Days__c from Master_Payment_Schedules__c  where Account__c in : setopp];
         system.debug('LstMPS ** '+LstMPS);
            if(LstMPS.Size() > 0){
                Delete LstMPS ;
                system.debug('MPS Record Delete** '+LstMPS);
            }
        List<TotalPS> LstTPS = New list<TotalPS>();
        
        for(id opp :setoppid){
           List<Payment_Schedules__c> LstPS = [select Date__c,Opportunity__c,Payment_Received_Date__c,Open_Principal__c,Total_Pay__c,InterestPmt__c,
                                                PrincipalPmt__c,PrincipalPmt_As_Per_Books__c,TDS__c,Net_Payment__c,Clearance__c,
                                                ClosingPrincipalBal_As_Per_Books__c,ClosingPrincipalBal__c,Balance_Days_for_NPA__c,Delinquent_Days__c 
                                                from Payment_Schedules__c  where Opportunity__c =: opp order by Date__c ASC];
            Integer psSize = LstPS.size();                                     
            
            //Checking for List of Opportunities on Paymemnt Schedules            
            for (Integer p = 0; p < psSize; p++) {
                Payment_Schedules__c ps = LstPS[p];
                TotalPS TPS = New TotalPS(); 
                TPS.opportunityid=ps.Opportunity__c;
                
                  Datetime testDate = ps.Date__c;
                  Date DT = Date.newInstance(testDate.year(), testDate.month(), testDate.day());
                  Integer DTA = (testDate.year())*100 + testDate.month();
                     
                  TPS.PSADate = DTA;
                TPS.PSDate = DT;
                TPS.PSPaymentReceivedDate=ps.Payment_Received_Date__c;  
                TPS.PSOpenPrincipal = ps.Open_Principal__c;
                TPS.PSTotalPay = ps.Total_Pay__c;
                TPS.PSInterestPmt = ps.InterestPmt__c;
                TPS.PSPrincipalPmt = ps.PrincipalPmt__c;
                TPS.PSPrincipalPmtAsPerBooks = ps.PrincipalPmt_As_Per_Books__c;
                TPS.PSTDS = ps.TDS__c;
                TPS.PSNetPayment = ps.Net_Payment__c;
                TPS.PSClosingPrincipalBalAsPerBooks = ps.ClosingPrincipalBal_As_Per_Books__c;
                TPS.PSClosingPrincipalBal = ps.ClosingPrincipalBal__c;
                TPS.PSClearance = ps.Clearance__c;
                TPS.PSDelinquentDays = ps.Delinquent_Days__c;
                TPS.PSBalanceDaysforNPA = ps.Balance_Days_for_NPA__c;
                
                system.debug('***TPS'+TPS.PSClosingPrincipalBal);
                system.debug('***TPS'+TPS.opportunityid);
                LstTPS.add(TPS);
                 system.debug('*****LstTPS'+LstTPS[p]);                     
                }
                
        }
         decimal closingbalance = 0;
                decimal openingbalance = 0;
                decimal interestpmt = 0;
                decimal pricipalpmt = 0;
                decimal pricipalbalasperbooks = 0;
                decimal closingbalasperbooks = 0;
                decimal TotalPay = 0;
                decimal NetPay = 0;
                decimal TDS = 0;
                decimal DelinquentDays=0;
                decimal BalanceDaysforNPA=0;
                Date dt;
                Date PRDate;
                Boolean clearence;
                            
               
                system.debug('*****LstTPS'+LstTPS);
        
                Integer LstTPSSize = LstTPS.Size();
        system.debug('***LstTPSSize'+LstTPSSize);
        for(Integer k = 0 ;  k< LstTPSSize ; k++ ){
            system.debug('opporunityid'+LstTPS[k].opportunityid);
            system.debug('***TPS'+LstTPS[k].PSClosingPrincipalBal);
        }
        for(payment_schedules__c ps1:paysch){
        for(Integer J = 0 ;  J< LstTPSSize ; J++ ){
            system.debug('*****LstTPS'+mapaccount.get(LstTPS[J].opportunityid));
            
            if(LstTPS[J].opportunityid==ps1.Opportunity__c){
                    
                        If (J == 0) {
                    
                        if (LstTPS[J].PSClosingPrincipalBal !=NULL) closingbalance = LstTPS[J].PSClosingPrincipalBal;
                        if (LstTPS[J].PSOpenPrincipal!=NULL) openingbalance =  LstTPS[J].PSOpenPrincipal;
                        if (LstTPS[J].PSInterestPmt !=NULL) interestpmt =  LstTPS[J].PSInterestPmt;
                        if (LstTPS[J].PSPrincipalPmt !=NULL) pricipalpmt =  LstTPS[J].PSPrincipalPmt;
                        if (LstTPS[J].PSPrincipalPmtAsPerBooks!=NULL) pricipalbalasperbooks =  LstTPS[J].PSPrincipalPmtAsPerBooks;
                        if (LstTPS[J].PSClosingPrincipalBalAsPerBooks!=NULL) closingbalasperbooks =  LstTPS[J].PSClosingPrincipalBalAsPerBooks;
                        if (LstTPS[J].PSTotalPay !=NULL) TotalPay =  LstTPS[J].PSTotalPay;
                        if (LstTPS[J].PSNetPayment!=NULL) NetPay =  LstTPS[J].PSNetPayment;
                        if (LstTPS[J].PSTDS !=NULL ) TDS =  LstTPS[J].PSTDS;
                        if (LstTPS[J].PSPaymentReceivedDate !=NULL) PRDate = LstTPS[J].PSPaymentReceivedDate ;
                        if (LstTPS[J].PSDate !=NULL) dt = LstTPS[J].PSDate ;
                        if (LstTPS[J].PSClearance !=NULL) clearence= LstTPS[J].PSClearance ;
                        if (LstTPS[J].PSDelinquentDays !=NULL) DelinquentDays= LstTPS[J].PSDelinquentDays ;
                        if (LstTPS[J].PSBalanceDaysforNPA !=NULL) BalanceDaysforNPA= LstTPS[J].PSBalanceDaysforNPA ;
                    }Else {
                        if(LstTPS[J].PSADate == LstTPS[J-1].PSADate ){
                                                              
                            if (LstTPS[J].PSClosingPrincipalBal !=NULL) closingbalance = closingbalance + LstTPS[J].PSClosingPrincipalBal;
                            if (LstTPS[J].PSOpenPrincipal!=NULL ) openingbalance = openingbalance + LstTPS[J].PSOpenPrincipal;
                            if (LstTPS[J].PSInterestPmt !=NULL)  interestpmt = interestpmt + LstTPS[J].PSInterestPmt;
                            if (LstTPS[J].PSPrincipalPmt !=NULL) pricipalpmt = pricipalpmt + LstTPS[J].PSPrincipalPmt;
                            if (LstTPS[J].PSPrincipalPmtAsPerBooks!=NULL) pricipalbalasperbooks = pricipalbalasperbooks  + LstTPS[J].PSPrincipalPmtAsPerBooks;
                            if (LstTPS[J].PSClosingPrincipalBalAsPerBooks!=NULL) closingbalasperbooks = closingbalasperbooks + LstTPS[J].PSClosingPrincipalBalAsPerBooks;
                            if (LstTPS[J].PSTotalPay !=NULL) TotalPay = TotalPay + LstTPS[J].PSTotalPay;
                            if (LstTPS[J].PSNetPayment!=NULL) NetPay = NetPay + LstTPS[J].PSNetPayment;
                            if (LstTPS[J].PSTDS !=NULL ) TDS =  TDS + LstTPS[J].PSTDS;
                            if (LstTPS[J].PSPaymentReceivedDate !=NULL) PRDate = LstTPS[J].PSPaymentReceivedDate;
                            if (LstTPS[J].PSDate !=NULL) dt = LstTPS[J].PSDate ;
                            // Checking True or False(checkbox) value of Clearance(Field) in PaymentSechduels and assign To MasterPaymentSchedules
                            if (LstTPS[J].PSClearance !=NULL)
                            if(LstTPS[J].PSClearance == False){
                              clearence= False ;
                              }
                             // Checking Minimum value of  Balance Days for NPA(Field) in PaymentSechduels and assign To MasterPaymentSchedules
                             if (LstTPS[J].PSBalanceDaysforNPA !=NULL)    
                             if (LstTPS[J].PSBalanceDaysforNPA < LstTPS[J-1].PSBalanceDaysforNPA ){
                              BalanceDaysforNPA = LstTPS[J].PSBalanceDaysforNPA ;
                              }
                           
                             // Checking Maximum value of DelinquentDays (Field) in PaymentSechduels and assign To MasterPaymentSchedules
                            if (LstTPS[J].PSDelinquentDays !=NULL) 
                            if(LstTPS[J].PSDelinquentDays > LstTPS[J-1].PSDelinquentDays ){
                            DelinquentDays = LstTPS[J].PSDelinquentDays ;
                           }
                           
                           
                        }else{ 
                          Master_Payment_Schedules__c MPS = new Master_Payment_Schedules__c();  
                            
                            MPS.ClosingPrincipalBal__c = closingbalance ; 
                            MPS.Open_Principal__c = openingbalance;
                            MPS.InterestPmt__c = interestpmt;
                            MPS.PrincipalPmt__c = pricipalpmt;
                            MPS.PrincipalPmt_As_Per_Books__c = pricipalbalasperbooks ;
                            MPS.ClosingPrincipalBal_As_Per_Books__c = closingbalasperbooks;
                            MPS.Total_Pay__c = TotalPay;
                            MPS.Net_Payment__c = NetPay;
                            MPS.TDS__c = TDS ;
                            MPS.Date__c = dt ;
                            MPS.Payment_Received_Date__c = PRDate;
                            MPS.Clearance__c = clearence;
                            MPS.Delinquent_Days__c = DelinquentDays;
                            MPS.Balance_Days_for_NPA__c = BalanceDaysforNPA;
                            
                            MPS.Account__c = mapaccount.get(ps1.Opportunity__c) ;  
                          
                            LstNewMPS.add(MPS); 
                            system.debug('***LstTPS'+LstTPS[J].opportunityid+'closingbal'+MPS.ClosingPrincipalBal__c);
            system.debug('****ps1'+ps1.Opportunity__c);
                                                      
                            if (LstTPS[J].PSClosingPrincipalBal !=NULL) closingbalance = LstTPS[J].PSClosingPrincipalBal;
                            if (LstTPS[J].PSOpenPrincipal!=NULL ) openingbalance =  LstTPS[J].PSOpenPrincipal;
                            if (LstTPS[J].PSInterestPmt !=NULL) interestpmt =  LstTPS[J].PSInterestPmt;
                            if (LstTPS[J].PSPrincipalPmt !=NULL) pricipalpmt =  LstTPS[J].PSPrincipalPmt;
                            if (LstTPS[J].PSPrincipalPmtAsPerBooks!=NULL) pricipalbalasperbooks =  LstTPS[J].PSPrincipalPmtAsPerBooks;
                            if (LstTPS[J].PSClosingPrincipalBalAsPerBooks!=NULL) closingbalasperbooks =  LstTPS[J].PSClosingPrincipalBalAsPerBooks;
                            if (LstTPS[J].PSTotalPay !=NULL) TotalPay =  LstTPS[J].PSTotalPay;
                            if (LstTPS[J].PSNetPayment!=NULL) NetPay =  LstTPS[J].PSNetPayment;
                            if (LstTPS[J].PSTDS !=NULL ) TDS =  LstTPS[J].PSTDS;
                            if (LstTPS[J].PSPaymentReceivedDate !=NULL) PRDate = LstTPS[J].PSPaymentReceivedDate ;
                            if (LstTPS[J].PSDate !=NULL) dt = LstTPS[J].PSDate ;
                            if (LstTPS[J].PSClearance !=NULL) clearence = LstTPS[J].PSClearance ;
                            if (LstTPS[J].PSDelinquentDays !=NULL) DelinquentDays = LstTPS[J].PSDelinquentDays ;
                            if (LstTPS[J].PSBalanceDaysforNPA !=NULL) BalanceDaysforNPA = LstTPS[J].PSBalanceDaysforNPA ;
                        
                        }  
                    }      
            }
        }
            Master_Payment_Schedules__c MPS = new Master_Payment_Schedules__c();  
                            
                            MPS.ClosingPrincipalBal__c = closingbalance ; 
                            MPS.Open_Principal__c = openingbalance;
                            MPS.InterestPmt__c = interestpmt;
                            MPS.PrincipalPmt__c = pricipalpmt;
                            MPS.PrincipalPmt_As_Per_Books__c = pricipalbalasperbooks ;
                            MPS.ClosingPrincipalBal_As_Per_Books__c = closingbalasperbooks;
                            MPS.Total_Pay__c = TotalPay;
                            MPS.Net_Payment__c = NetPay;
                            MPS.TDS__c = TDS ;
                            MPS.Date__c = dt ;
                            MPS.Payment_Received_Date__c = PRDate;
                            MPS.Clearance__c = clearence;
                            MPS.Delinquent_Days__c = DelinquentDays;
                            MPS.Balance_Days_for_NPA__c = BalanceDaysforNPA;
                            
                            MPS.Account__c = mapaccount.get(ps1.Opportunity__c) ;  
                          
                            LstNewMPS.add(MPS); 
            
        }
             Insert LstNewMPS;
                system.debug('MPS Records Inserted** '+LstNewMPS);
    }
     global void finish(Database.BatchableContext BC){

    }

}
Hi Guys,

I have a requirement ..i  need to create a visualforce page which will display all account names in custom picklist.
Please help me on this.

Thanks in Advance.
Smitha

I am trying to construct a map of one object (c2g_codaCompany__C) name with another object (Journal_Stagings__c) id. But I am receiving one error, please help?

Invalid bind expression type of Journal_Staging__c for Id field of SObject c2g__codaCompany__c

Code: 

List<Journal_Staging__c> journals = new List<Journal_Staging__c>();
        // map to get all companies
        Map<Id, c2g__codaCompany__c> companies = New Map<Id, c2g__codaCompany__c>([Select Id, Name FROM c2g__codaCompany__c]);
        // for each company, create a journal, setting that company id on the journal - add this to list
        for(c2g__codaCompany__c c : companies.keySet()) {
			journals.add(new Journal_Staging__c(
            // set company lookup - only put id not name
			Company__c = c.Id));
		}
        // insert journals to get id for jlis
		insert journals;
        // map of company name to journal id
        List<Journal_Staging__c> getNewJournals = [Select Id, Name, Company__c FROM Journal_Staging__c];
        Map<String, Id> companyJournal = New Map<String, Id>();
        for(Journal_Staging__c j : [SELECT Name FROM c2g__codaCompany__c WHERE Id=: getNewJournals]) {
			companyJournal.put(j.Name, j.Id);
		}
Hi, 
I want to develop a page which has two radio button as options : radio1  and radio2 . on click of radio1 a form of account should be avaialble and on click of radio2 a form of contact should be available. 

I have my code but on click of both radio button it is redirecting to contact page only. can u help me to solve my issue

<apex:page controller="AccController">
 <apex:form >
 <apex:pageBlock id="pgblk"> 
 <apex:selectRadio id="radioid" layout="pageDirection">
 <apex:selectOption  itemLabel="radio1" itemValue="1"></apex:selectOption>
 <apex:actionSupport event="onclick" action="{!AccForm}">
 </apex:actionSupport>
 
 <apex:selectOption itemLabel="radio2" itemValue="2"></apex:selectOption>
 <apex:actionSupport event="onclick" action="{!ContForm}">
 </apex:actionSupport>
 </apex:selectRadio>
 
 </apex:pageBlock>
 </apex:form>
</apex:page>

Here is my controller
public class AccController 
{
 public PageReference AccForm()
 {
 PageReference Page = new PageReference('/apex/CreateAcc');
 Page.setRedirect(true);
 return Page;
 }
 
 public PageReference ContForm()
 {
 PageReference Page = new PageReference('/apex/CreateContact');
 Page.setRedirect(true);
 return Page;
 }
}
Hi Everyone !

I want to make a validation rule on the object "Opportunity", the rule is basically :

We want to check the Stage of the opportunity , if the opp is in stage = Negotiation / Verbal / Contract / Launched / Invoiced / Closed , and the field "agent" (Sales_Agent__c) is different from "None (Sales Agent)" and the field "Agent_Commission__c" is blank and the field "Agent_Commission_Amount_Manual__c" is blank.

So if all this is gathered, an error message is displayed:"Please check the agent commissions. ..."

So in order to do that , i have created a validation rule , like this:

AND(
OR(
text(StageName) = "Negotiation",
text(StageName) = "Verbal",
text(StageName) = "Contract",
text(StageName) = "Launched",
text(StageName) = "Invoiced",
text(StageName) = "Closed",
OR(
ISBLANK( Agent_Commission__c )
,
Sales_Agent__c<>"None (Sales Agent)"
,
ISBLANK(Agent_Commission_Amount_Manual__c)))

But i have an issue , when we apply the validation rule , even if the field "Agent" is equal to "None (Sales Agent)" the rule still applies.

Thanks for your help !

trigger OppPrimaryConRole on Opportunity (before update) {
for(Opportunity opp: trigger.new)
{
    
    try
    {
        string BRL_contactId = opp.BRL_Contact__c;
        string Renewal_contactid = opp.Renewal_Contact__c;
       
            List<OpportunityContactRole> primarycontactrole = [select contactid,contact.email from OpportunityContactRole where isprimary=true and opportunityid= :opp.id limit 1];
            if(primarycontactrole.size()>0)
            {
                if (BRL_contactid != primarycontactrole[0].Id )
                {
                //opp.put('Primary_contact__c',primarycontactrole[0].contactId);
                system.debug('primary id is'+ primarycontactrole[0].contactId);
                system.debug('renewal email is'+ primarycontactrole[0].contact.email);
                opp.Renewal_Contact__c = primarycontactrole[0].contactId;
                opp.BRL_Contact__c = primarycontactrole[0].contactId;
                opp.BRL_Renewal_Email__c = primarycontactrole[0].contact.email;
                system.debug('renewal contact id is'+ opp.Renewal_Contact__c);
                system.debug('BRL Contact is'+ opp.BRL_Contact__c);
            }
      }
    }
    catch(exception e)
    {
        system.debug('Error:'+e);
    }
}
}
I have a requirement as group of user having one profile assigned to them .. they have access to Standard objects as well as cutom object..through profile level, i can't unchecked the object permission for standard object.. as profile provides the most restrictive access.
But if for the same profile , i have two users to whom i dont want to give access to Account & contact object... how it will be done,,,as per my understanding,,,permission set provide additional accces.it never restricts the permission which is set at profile level


 
While saving the vf page
"<apex:page StandardController="opportunity">
<apex:form >
<apex:commandButton action="{!URLFOR($Action.Opportunity.Share, Opportunity.Id)}" value="Create New Object"/>
</apex:form>
</apex:page>"
It throws me this error. What Am I Missing?
Hi All,

when I'm trying to call application event then I'm getting below error and $A.get(event) is returning undefined which is marked bold in the below code.
Error : Uncaught TypeError: Cannot read property 'setParams' of undefined
 
CalendarView.cmp  :

<aura:component controller="CalendarController" implements="force:hasRecordId,force:hasSObjectName,force:appHostable" access="global">
<aura:registerEvent name="loadMyEvent" type="harshabr:ResultEvent"/>
    
    <ltng:require styles="/resource/gpcal_lex_yo_SLDS0121/assets/styles/salesforce-lightning-design-system-ltng.css,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.css" 
	scripts="/resource/gpcal_lex_yo_jquery,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/lib/moment.min.js,/resource/gpcal_lex_yo_fullcalendar/fullcalendar-2.6.0/fullcalendar.js"
              
	afterScriptsLoaded="{!c.doInit}"
/>
	<aura:attribute name="recordId" type="String" access="global"/>
	<aura:attribute name="sObjectName" type="String" access="global"/>	
	<aura:attribute name="user_id" type="String" />
    
    <aura:attribute name="cal" type="Boolean" default="true" />
	<aura:attribute name="evtRec" type="List" />
    <aura:attribute name="eventId" type="String" />
    
     <aura:renderIf isTrue="{!v.cal}">
        <div id='calendar'>
        <!-- <c:EventsList evtId="{!v.eventId}" /> -->
	</div>
    </aura:renderIf>    
      
</aura:component>

CalendarViewController :

({
	doInit: function(component, event, helper){
        $('#calendar').fullCalendar({
	    	defaultView: 'month',
	    	allDaySlot: false,
	    	selectable: true,
			selectHelper: true,
			select: function(start, end) {
				
				var title = prompt("Please enter subject of event:");
				var eventData;
				if (title) {

					var action = component.get("c.createNewEvent");
					var params = { 
						start_time : start.format("YYYY-MM-DD HH:mm:ss"),
						end_time   : end.format("YYYY-MM-DD HH:mm:ss"),
						user_id    : component.get("v.user_id"),
						what_id    : component.get("v.recordId"),
						sobjectName    : component.get("v.sObjectName"),
						title      : title		
					};
					action.setParams(params);

					action.setCallback(this, function(actionResult) {				        				        
				        if( actionResult.getReturnValue() ){
				        	$('#calendar').fullCalendar( 'refetchEvents' );
				        	console.log("save successful");
				        }
				        else{

				        	alert( "Save failed for some reason." );
				        }
				    });
				    
				    $A.run(function(){
				    	$A.enqueueAction(action);						
				    });

				    

				}
				$('#calendar').fullCalendar('unselect');
			},
	    	events: function(start, end, timezone, callback) {
	    		var user_id = component.get("v.user_id");	    		
				var action = component.get("c.getEvents");
				action.setParams(
					{ 
						start_time : start,
						end_time   : end,
						user_id    : user_id		
					}
				);

				action.setCallback(this, function(actionResult) {
			        callback(JSON.parse(actionResult.getReturnValue()));
			    });
			    $A.enqueueAction(action);				
	    	},
            eventClick: function(calEvent, jsEvent, view) {
    	        console.log('gm calEvent '+calEvent);
                console.log('gm1 '+calEvent.id);
                var evtId = calEvent.id;
                component.set("v.cal",true);
                var evt = $A.get("e.c:ResultEvent");
            	console.log(evt);
                console.log(evtId);
				evt.setParams({ "pass_result": evtId });
				evt.fire();
                
		    }
	    });
	}
})


ResultEvent.evt :
<aura:event type="APPLICATION">
    <aura:attribute name="pass_result" type="String"/>
</aura:event>

app:

<aura:application extends="force:slds">
    <c:CalendarView />
    <c:EventsList />
</aura:application>


EventsList.cmp :
<aura:component controller="CalendarController" access="global">
  <aura:attribute name="eventData" type="List" access="global" />
    <aura:handler event="harshabr:ResultEvent" action="{!c.getMyEvents}" />
    
    <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
    <thead>
      <tr class="slds-text-heading--label">
        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Subject">Subject</div></th>
        <th scope="col"><div class="slds-truncate" title="StartDateTime">StartDateTime</div></th>
      </tr>
    </thead>
    <tbody>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.eventData}" var="e">
        <tr>
          <th scope="row"><div class="slds-truncate" title="{!e.Id}">{!e.Id}</div></th>
          <td><div class="slds-truncate" title="{!e.Subject}">{!e.Subject}</div></td>
          <td><div class="slds-truncate" title="{!e.StartDateTime}">{!e.StartDateTime}</div></td>
          <td>
            <form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!e.Name}" class="account-name" />
             
               <!--  Use a Lightning Base Component
                To display an icon next to the label-->
             
              <lightning:button label="Delete"
                                iconName="utility:delete"
                                iconPosition="left"
                                variant="destructive"
                                />
            </form>
          </td> 
        </tr>
      </aura:iteration>
    </tbody>
  </table>
</aura:component>

 EventsListController :
({
getMyEvents: function(component, event, helper){
        var action = component.get('c.getEventss');
    	var evtIds = event.getParam("pass_result");
      	console.log('GM evtId '+evtIds);
      	action.setParams({
        	  "eventId": evtIds
      	});
    	// Set up the callback
    	var self = this;
    	action.setCallback(this, function(actionResult) {
     		component.set('v.eventData', actionResult.getReturnValue());
    	});
      	console.log("GM res "+component.get('v.eventData'));
    	$A.enqueueAction(action);
    },
  deleteAccount: function(component, event, helper) {
    // Prevent the form from getting submitted
    event.preventDefault();

    // Get the value from the field that's in the form
    var accountName = event.target.getElementsByClassName('account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)');
  }
})
  • February 06, 2018
  • Like
  • 0
while saving 11th  record it should show an error while saving that limit had exceeded
I am unable to download app in AppExchange. How do I obtain permission for both “Create AppExchange packages” and “Upload AppExchange packages”? Thanks!
hi friends,

               The following code is not working for delete event in trigger. But it's working fine for after insert and after update events.
I have custom object Revenue__c. It has master detail relationship with Account. I want to update Account field values with revenue field values whenever the revenue is inserted,updated and deleted.Can any one suggest me what is the wrong in the following code
trigger revenuetrigger on Revenue__c(after insert, after update,after delete){
if(trigger.isinsert || trigger.isupdate ){
new RevenueCal().populateRevenu(trigger.new);
}if(trigger.isdelete){
new RevenueCal().populateRevenu(trigger.old);
}
}
Apex class:
public class RevenueCal {
    Map<Id,Account> accmap = new Map<Id,Account>();
   public List<Id> ids = new List<Id>(accmap.keySet());
    public List<Account> childsToupdate = new List<Account>();
    //ids.addAll();
   public map<String,Revenue__c> linkIdMap = new Map<String,Revenue__c>();
    List<Account>listToUpdate = new List<Account>();
    public void populateRevenue(List<Revenue__c> revlist){
        for(Revenue__c rev : revlist){
           linkIdMap.put(rev.Reporting_Link_Id__c, rev);
          
        }
        //update listToupdate;
        for(Account a : [SELECT Id, Name,Link_Id__c,ParentId,Reporting_Link_Id__c,Revenue_Product__c,
                         Revenue_Service__c,Revenue_Cloud__c FROM Account]){
            if(linkIdmap.containsKey(a.Reporting_Link_Id__c)){
                a.Revenue_Product__c = linkIdmap.get(a.Reporting_Link_Id__c).Product_Revenue__c;
                a.Revenue_Service__c = linkIdmap.get(a.Reporting_Link_Id__c).Service_Revenue__c;
                a.Revenue_Cloud__c = linkIdmap.get(a.Reporting_Link_Id__c).Cloud_Revenue__c;
                childsToupdate.add(a);
            }
        }
        try{
        update childsToupdate;
        }Catch(Exception e){
            system.debug('update failes due to:'+e.getMessage());
        }
    }
}

I am trying to display a selectList in a visualforce page using a custom controller i built.

I get an "List has no rows for assignment to SObject" error when trying to preview the page, but running the query in the developer console, returns the rows.

here is my page:
 

<apex:page Controller="BpmIcountPayment">
    <apex:param name="first_name" value="Account.FirstName"/>
    <apex:param name="last_name" value="Account.LastName"/>
    <apex:param name="id" value="Account.idnumber__c"/>
    <apex:param name="address" value="Account.Address"/>
    <apex:form >
        <apex:selectList value="{!productsTitle}" multiselect="false">
            <apex:selectOptions value="{!ProductsLov}"></apex:selectOptions>
        </apex:selectList>
        </apex:form>
</apex:page>

and my controller:

public class BpmIcountPayment{

    private final Account account;

    public String productsTitle {
      get { return 'products for sale'; }
      set;
    }
 
    public BpmIcountPayment() {
        account = [SELECT Id, Name, Site FROM Account
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getAccount() {
        return account;
    }

    public List<SelectOption> getProductsLov() {
        List<SelectOption> products = new List<SelectOption>();
        List<Product2> productsList = [SELECT Id, Name, Family 
                                      FROM Product2 
                                      WHERE (Family = 'ShopProduct') 
                                      OR (Family = 'CourseParent') 
                                      OR (Family = 'SFCourseProgram')];

        system.debug(productsList);
        for (Product2 currProduct : productsList) {
            products.add(new SelectOption(currProduct.Id, currProduct.Name));
        }

        return products;
    }
}
trigger trigger52 on India__c (after insert) {
  list<san_francisco__c> con =new list<san_francisco__c>();  

    for(India__c h : trigger.new){
     san_francisco__c s = new san_francisco__c();
      s.Name=h.Name;
        s.Company__c=h.Company__c;
        s.Mobile__c=h.Mobile__c;
           s.Email__c=h.Email__c;
        con.add(s);
        
        
    }
    insert con;
}
Am, using the concept of Wrapper class. I want to delete recently created contact record from pageBlockTable.
I am facing Unknown property 'SingleRecordDelete.ContactWrp.id' Error
Here is What I did--

VF page

<apex:page controller="SingleRecordDelete">
  <apex:form >
     <apex:pageBlock title="Contacts">
          <apex:pageBlockSection title="New Contact" columns="2" id="fresh">
              <apex:inputText label="FirstName" value="{!fname}" />
              <apex:inputText label="LastName" value="{!lname}"/>
              <apex:commandButton action="{!save}" value="Save" reRender="lab,fresh"/>
          </apex:pageBlockSection> 
         
          <apex:pageBlockSection title="ContactList" id="lab">
              <apex:pageBlockTable value="{!crp}" var="cy" id="update">
                  <apex:column headerValue="FirstName">
                      <apex:outputLabel value="{!cy.cn.firstname}"/>
                  </apex:column>
                  <apex:column headerValue="LastName">
                      <apex:outputLabel value="{!cy.cn.lastname}"/>
                  </apex:column>
                  <apex:column >
                         <apex:commandLink value="Delete" action="{!doDelete}" style="color:Red" reRender="lab">
                             <apex:param name="did" value="{!cy.id}" assignTo="{!did}"/>
                         </apex:commandLink>
                  </apex:column>
                  
              </apex:pageBlockTable>
                  
          </apex:pageBlockSection> 
               
     </apex:pageBlock>
  </apex:form>
</apex:page>

ApexClass
public with sharing class SingleRecordDelete {

    public String fname {get;set;}
    public String lname {get;set;}
    public String did {get;set;}
    
    public List<ContactWrp> crp {get;set;}
    
    public SingleRecordDelete(){
        crp = new List<ContactWrp>();
        
    }
    
    public void save(){
      Contact c = new Contact();
      c.firstname = fname;
      c.lastname = lname;
      insert c;
      crp.add(new ContactWrp(c));
      fname='';
      lname='';
    }
    
    public void doDelete()
    {
        List<Contact> contactToBeDelete = new List<Contact>();
        Contact cod = [select id from Contact where id =: did];
        contactToBeDelete.add(cod);
        delete contactToBeDelete;
    }
    
     public class ContactWrp{
    
      public Contact cn {get;set;}
      
        public ContactWrp(Contact cs){
            this.cn = cs;                   
        }
    }
}
I wrote a apex code which is triggerd when a particular filed in updated above a certain value. When i manually edit that field the code works fine. But the code had to be excute whenever the value is updated, it shouldnt wait until manual edit. The apex helps in assigning a account to particular queue.
the apex code is as follows : 
public class AssignLeadsUsingAssignmentRules
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
            Database.DMLOptions dmo = new Database.DMLOptions();
            dmo.assignmentRuleHeader.useDefaultRule= true;          
            Lead Leads=[select id from lead where lead.id in :LeadIds];
            Leads.setOptions(dmo);
            update Leads;
   }
}


Error message :  Error element myWaitEvent_myWait_myRule_1_event_0_SA1 (FlowActionCall).
An Apex error occurred: System.QueryException: List has more than 1 row for assignment to SObject


Can someone help me with this?. Thanks in advance.