• sivapriyaa maniam sivakumar
  • NEWBIE
  • 25 Points
  • Member since 2015
  • Consultant
  • Quadrobay Technologies LLP

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 9
    Replies
Hi all, Please find the scenario given below
  1. Create a custom field as picklist in Account object as “ Integration” and the value as A,B,C & not a required + restricted picklist.
  2. Always the fields updates only in the backend. Once the fields gets updated, it should show either in classic page/lightning page/VFP.
  Conditions:
  1. Whole record page should not refresh to update value, it should only update the field alone.
Can anyone please help me on how to acheive this. Thanks in advance

Regards,
Sivapriyaa M S
Hi All,

We have two Visual force page and Apex class.

First Visualforce page - Retrives the table data based on the picklist.
Second Visualforce page - Export those Table value with picklist parameters in Excel Sheet.
Results - retrieves the datas in excel sheet based on the picklist values.
This Flow is working fine in normal Visual force page preview.

But In community Builder :
We have added two visual force page in communities.

First Visualforce page - Retrives the table data based on the picklist.then,export button/link is clicked it redirects to second visual force page (export as excel).

Result -  Returns with Empty Excel sheet.

 Reason : Picklist value is not passed to second VFP(Export Functionality)

Need Help : How to pass the picklist parameter from First Visual force page to another VFP in community Builder pages.

Thanks in Advance
 
Hi Everyone,

Requirenment: Every user should recall the approval process.

I follow this link for email service - https://salesforce.stackexchange.com/questions/122989/recall-approval-process-from-apex-for-non-admin-profile

I configured the email service and wrote the apex classes also ( code as below)
 
global class RecallEmailServiceNST implements Messaging.InboundEmailHandler 
{
    public RecallEmailServiceNST(ApexPages.StandardController controller){}
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope envelope)
    {  
        Messaging.InboundEmailResult emailresult = new Messaging.InboundEmailResult();
        system.debug(email.plainTextBody);
        if(email.subject.containsIgnoreCase('Recall NST'))
        {
            String str = email.subject.normalizeSpace();
            String NSTNumber = str.substring(str.indexOf('-')+1,str.length());
            System.debug('NSTNumber :'+NSTNumber);            
            NST__c con = [Select Id,Name From NST__c WHERE Name=:NSTNumber];
            try
            {        
            List<ProcessInstance> pi = [SELECT Id FROM ProcessInstance WHERE TargetObjectId=:con.Id AND Status='Pending'];  
              System.debug('pi :'+pi );  
            if(pi.size()==0)
                return emailresult;
            List<ProcessInstanceWorkitem> piw = [SELECT Id,ActorId,ProcessInstanceId FROM ProcessInstanceWorkitem WHERE Actor.Email=:email.fromAddress and ProcessInstanceId=:pi[0].Id];            
           System.debug('piw :'+piw ); 
            if(piw.size()==0)
                return emailresult;
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();                        
      /*      if(email.plainTextBody.containsIgnoreCase('<approved>'))
            {
                req.setComments('Request Approved by Email Approval..!!');
                req.setAction('Approve');
            }                                    
            else if(email.plainTextBody.containsIgnoreCase('<rejected>'))
            {
                req.setComments('Request Rejected by Email Approval..!!');
                req.setAction('Reject');
            }
            else */if(email.plainTextBody.containsIgnoreCase('<recalled>'))
            {
                req.setComments('Request Recalled by Email Approval..!!');
                 System.debug('Request Recalled by Email Approval..!!' ); 

                req.setAction('Removed');        
                 System.debug('Removed' ); 
            }
            req.setWorkitemId(piw[0].Id);                                  
            Approval.ProcessResult result = Approval.process(req);
            FeedItem a = new FeedItem(ParentId=con.Id,Type='TextPost');  
            if(result.isSuccess())                                    
            {
                a.Body='Email received from Approver and the process was '+result.getInstanceStatus();                
            }
            else if(!result.isSuccess())
            {
                a.Body='Email received from Approver but some error occured, please contact sys admin';
            }
            a.Body+=email.plainTextBody;
            Insert a;
            }
            catch(Exception e)
            {
                system.debug(e);
            }            
        }
        return emailresult;       
    } 
}

Error: 
A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

>>> recallemailservicenst@y-1sgjk0kf5kumx9gjf0ri0ajl9jp654aldvztnd1l5a4q
>>> vbjq7y.0q-cuhyeas.cs64.apex.sandbox.salesforce.com (Undelivered): 
>>> 550 An internal error occured

couls you please assist us to fix the internal server error.

Thanks
sivapriyaa  M S
Hi,

We have custom button (Modify NST) in the NST Object (custom object).
Once the Approval button clicks, the status is changed to submitted.
After the Approval, Modify NST button enables. If we click the button, the recall action is taken and the record becames unlock.

ISSUE: We have an issue in recall approval process for User (other than record owner and admin). 
Apex code : ApprovalRecall
global class approvalRecall
{
    webservice static void recallApproval(Id recId)    
    {      
        system.debug('recId****'+recId);

     NST__c[] nsts = [SELECT Id,NST_Status__c from NST__c WHERE Id=:recId];
        ID ObjectId=recId;
        List<ProcessInstance> pi = new  List<ProcessInstance>([SELECT Id FROM ProcessInstance WHERE TargetObjectId =: ObjectId ]);
               
       if( (pi.size()==0))
       {
           for(NST__c nst : nsts )
{
    nst.NST_Status__c='Draft';
    update nst;
    
}
       }
      
     else
     {
         List<ProcessInstanceWorkitem> piwi =new List<ProcessInstanceWorkitem>( [SELECT Id FROM ProcessInstanceWorkitem WHERE ProcessInstanceId=: pi[0].id]);
     
        if((piwi!=null ) && (piwi.size()>0))
     {
        Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
       
        req.setAction('Removed');       // steps to recall the approval process
 
        req.setWorkitemId(piwi.get(0).Id);
          Approval.process(req,false);
           }
    
        // Unlock the NST
Approval.UnlockResult[] urList = Approval.unlock(nsts, false);
for(NST__c nst : nsts )
{
    nst.NST_Status__c='Draft';
    update nst;
    
}
 }
This apex class is working when the record owner and Admin clicks the "Submit for Approval" and both can view the "Recall" button and access the process. But other than record owner and admin i.e., user unable to view the recall button when the  record owner or Admin clicks the "Submit for Approval".

My requirement is " whoever submit the approval, all user should recall the approval process.

Could you please assist me to fix this issue.

Please let me know if you need any other information.

Thanks in advance!!!

Regards
Sivapriyaa M S
Hi all,

I am facing the "Apex CPU Time Limit Exceed Error"

When i am trying to attempt the account the APEX CPU Time limit exceed error occurs.

Could you please tell me why this error occur and how to fix this issue. Please let me know if you need additional information.

Following are the flow execution report and it shows only 4 opportunity record ids. 

Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 1 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0060H00000jhSDWQA2
myVariable_current = 0060H00000jhSDWQA2
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (0060H00000jhSDWQA2)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 1 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0060H00000jhXUbQAM
myVariable_current = 0060H00000jhXUbQAM
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (0060H00000jhXUbQAM)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 1 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0060H00000jhZ5HQAU
myVariable_current = 0060H00000jhZ5HQAU
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (0060H00000jhZ5HQAU)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 0 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 006i000000aa4TcAAI
myVariable_current = 006i000000aa4TcAAI
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (006i000000aa4TcAAI)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.

Thanks in advance....

Regards,
Sivapriyaa M S
Hi Everyone,

I have faced the issue that the "DatedConversionObject" is not visible in Objects.

I have enable the "Multi-currency feature" in sandbox. I can access the object only via SOQL.

I dont know why the object is not visible in object after the "Multi-currency feature" is enabled in sandbox.

Is the object can only accessible via apex coding? or view it in Objects?

Could you please help me to fix the issue.

Thanks
Sivapriyaa M S
Hi,
I am getting an error  as CPU Time Limit Exceed. 

Trigger Code : Its Update a Distributor Value from  Account  To Quote,QuoteLineItem & OpportunityLineItem Based on Product or Service.
trigger DistributorDiscountChangeTrigger on Account (after update) {
    System.debug('Trigger Entered');
    Map<Id, Account> accByIds = new Map<Id, Account>();
    Map<Id, Account> accsByIds = new Map<Id, Account>();
    
    for ( Account acc: Trigger.NEW) 
    {
        
        if ( acc.Distributor_Discount_Service__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Service__c || acc.Distributor_Discount_Product__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Product__c ) {
            accByIds.put( acc.Id, acc);
         
        }
    }

    if ( !accByIds.isEmpty() ) {
 
        
        Map<Id, Opportunity> oppByIds = new Map<Id,Opportunity>( [ SELECT Id, Distributor__c FROM Opportunity WHERE Distributor__c IN: accByIds.keySet() AND IsClosed = FALSE]);        
 
        List<OpportunityLineItem> oppProds = [ SELECT Id, Distributor_Discount_Product_HIDDEN__c,Distributor_Discount_Service_HIDDEN__c,Opportunity.Distributor__c, PricebookEntry.Product2.Family, Distributor_Discount_1__c, Opportunity.Distributor__r.Distributor_Discount_Service__c, Opportunity.Distributor__r.Distributor_Discount_Product__c FROM OpportunityLineItem WHERE OpportunityId IN: oppByIds.keySet()];
      
        List<QuoteLineItem> qlis = [ SELECT Id, Distributor_Discount_1__c, Quote.Opportunity.Distributor__c, PricebookEntry.Product2.Family, Quote.Opportunity.Distributor__r.Distributor_Discount_Service__c, Quote.Opportunity.Distributor__r.Distributor_Discount_Product__c FROM QuoteLineItem WHERE Quote.OpportunityId IN: oppByIds.keySet()];
       
        List<Quote> oppqt = [ SELECT Id, Distributor_Service_Discount_Temp__c,Opportunity.Distributor__c,Distributor_Product_Discount_Temp__c,Distributor__c FROM Quote WHERE Quote.OpportunityId IN: oppByIds.keySet()];
       
         for ( Quote qt: oppqt ) 
         {
              System.debug('Enter For Loop-Quote');
            if ( qt.Opportunity.Distributor__c == null ) {
                qt.Distributor_Product_Discount_Temp__c  = 0;
                qt.Distributor_Service_Discount_Temp__c=0;
                continue;
            }
            if ( qt.Opportunity.Distributor__c != null) {
                qt.Distributor_Product_Discount_Temp__c = accByIds.get( qt.Opportunity.Distributor__c ).Distributor_Discount_Product__c;
                 qt.Distributor_Service_Discount_Temp__c= accByIds.get( qt.Opportunity.Distributor__c ).Distributor_Discount_Service__c;
            }       
         }

        for ( QuoteLineItem qli: qlis ) {
     
            if ( qli.Quote.Opportunity.Distributor__c == null ) {
                qli.Distributor_Discount_1__c = 0;
                continue;
            }
            if ( qli.PricebookEntry.Product2.Family == 'Service') {
                   
                qli.Distributor_Discount_1__c = accByIds.get(qli.Quote.Opportunity.Distributor__c).Distributor_Discount_Service__c;
            } else if ( qli.PricebookEntry.Product2.Family != 'Non-Discount' ) {
                    
                qli.Distributor_Discount_1__c = accByIds.get(qli.Quote.Opportunity.Distributor__c).Distributor_Discount_Product__c;
            } else {

                qli.Distributor_Discount_1__c = 0;
            }
           } 
        
        for ( OpportunityLineItem oli: oppProds ) {
            System.debug('Enter For Loop-OpportunityLineItem');
            if ( oli.Opportunity.Distributor__c == null ) {
                oli.Distributor_Discount_1__c  = 0;
               oli.Distributor_Discount_Product_HIDDEN__c=0;
                oli.Distributor_Discount_Service_HIDDEN__c=0;
                continue;
            }
            if ( oli.PricebookEntry.Product2.Family == 'Service') {
                oli.Distributor_Discount_1__c = accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Service__c;
                oli.Distributor_Discount_Service_HIDDEN__c=accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Service__c;
            } else if ( oli.PricebookEntry.Product2.Family != 'Non-Discount' ) {
                oli.Distributor_Discount_1__c = accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Product__c;
                oli.Distributor_Discount_Product_HIDDEN__c=accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Product__c;
            } else {
                oli.Distributor_Discount_1__c = 0;
            }
        }
    
         update qlis; 
        update oppqt;
        update oppProds;
  
        }

}

Please suggest a solution.

Thanks
Sivapriyaa M S
Hi,
Can anyone please tell me the solution.

Scenario:
By passing Academic Year & Student Name from VisualForce Page1 to VisualForce Page2 (Single Student Records-Student Profile,Academics,Family and Counselling) have to display 
2 VFP and 1 Apex Controller.
Issue:
For VisualForce Page 2, Apex Controller [getStud() & getstudentrec() ] didn't enter these two methods ,But ID is passing to the second VisualForce Page , another methods(getFamily() & getstudentcounsel()) are displayed.

Note: Totally 4 methods has to pass on the VisualForce Page 2 , out of 2 [getFamily() & getstudentcounsel()] is display other 2 [getStud() & getstudentrec() ] is not display.
Apex code:
public with sharing class StudentProfileListViewTest {
    
    private String soql {get;set;}
     public string StudentName {get;set;}
     public string Year {get;set;}
    public string School {get;set;}
    public CSM_Student_Profile__c studentrec;
public Student_Counselling_Attributes__c studentcounsel;
    public Student_Academic_Class__c stud{get;set;}
  ID qstr = System.currentPagereference().getParameters().get('Id');
    public List<Student_Academic_Class__c> StudDetail{get;set;}
    
    public StudentProfileListViewTest() {
     soql='SELECT Year__c,name,Student_Name__r.Name,Student_Name__r.Student_First_Name__c,Student_Name__r.Student_Last_Name__c,Student_Name__r.Student_Caste__c,Student_Name__r.State__c,Student_Name__r.City__c,Student_Name__r.Address__c,School_Name__r.School_Name__c from Student_Academic_Class__c order by Year__c limit 200';  

        runquery();
    }
     public void search_method() {
         
    soql='SELECT Year__c,name,Student_Name__r.Name,Student_Name__r.Student_First_Name__c,Student_Name__r.Student_Last_Name__c,Student_Name__r.Student_Caste__c,Student_Name__r.State__c,Student_Name__r.City__c,Student_Name__r.Address__c,School_Name__r.School_Name__c from Student_Academic_Class__c where Year__c!=null';  
      system.debug('Full Query'+soql);
      if (!StudentName.equals(''))
      soql += ' and Student_Name__r.Student_First_Name__c LIKE \''+String.escapeSingleQuotes(StudentName)+'%\'';  
       if (!Year.equals('selectst'))
      soql += ' and Year__c  LIKE \''+String.escapeSingleQuotes(Year)+'%\''; 

              system.debug('year'+year);  
    // run the query again
  runQuery();
     }

 public void runQuery() 
{

    try {
system.debug('Query'+soql);
      StudDetail= Database.query(soql);
 
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'+e));
    }
 
   }
     public List<selectoption> getAcademicYear()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Student_Academic_Class__c.Year__c.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
        options.add(new SelectOption('selectst','-- Select Academic Year --')); 
    for (Schema.PicklistEntry a : values) 
    {     
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 
} 
    
    public List<SelectOption> getSchoolName() {

    List<SelectOption> options = new List<SelectOption>();

    options.add(new SelectOption('selectprd','-- Select SchoolName --'));

    for(Schools_Master__c c : [select ID, School_Name__c from Schools_Master__c]){

        options.add(new SelectOption(c.ID, c.School_Name__c));

    } 

    return options;

}
    public PageReference StudPage(){
        System.debug('111111111111111');
        string id1 = apexpages.currentpage().getparameters().get('StudId');
       
         //stud= [SELECT Name, Student_Name__r.Name, Pass_Fail__c,Medium_of_Instruction__c, Year__c, (select subject_name__c, first_exam_marks__c,second_exam_marks__c,final_exam_marks__c from Student_Scores__r), Total_Marks__C, Total_Percentage__c, Math_Marks__C, Science_Marks__c, Social_Science_Marks__C, First_Language_Marks__C, Second_Language_Marks__C,  English_Language_Marks__c,School_Name__r.School_Name__c, School_Name__r.State__c, School_Name__r.Village_Name__c FROM Student_Academic_Class__c WHERE year__c = : year and Student_Name__c = : id1  ORDER BY name];
      system.debug(id1);
         system.debug(year);
        PageReference ref = new PageReference('/apex/testltning?id='+id1);
  
       ref.setRedirect(true);
        return ref;
    }
   
     
    public CSM_Student_Profile__c getstudentrec(){ 
        system.debug('22222');
        studentrec= [SELECT Name,Student_First_Name__c,Student_Last_Name__c,Student_Caste__c,State__c,City__c,Address__c,External_Student_Id__c FROM CSM_Student_Profile__c WHERE Id = :qstr ORDER BY name];
        system.debug('ID'+qstr);
        return studentrec;

    }
    
   public Student_Academic_Class__c getStud(){   
       system.debug('3333');
      return [SELECT Name, Student_Name__r.Name, Pass_Fail__c,Medium_of_Instruction__c, Year__c, (select subject_name__c, first_exam_marks__c,second_exam_marks__c,final_exam_marks__c from Student_Scores__r), Total_Marks__C, Total_Percentage__c, Math_Marks__C, Science_Marks__c, Social_Science_Marks__C, First_Language_Marks__C, Second_Language_Marks__C,  English_Language_Marks__c,School_Name__r.School_Name__c, School_Name__r.State__c, School_Name__r.Village_Name__c FROM Student_Academic_Class__c WHERE year__c = : year  and Student_Name__c = : qstr  ORDER BY name];
     
        
    }
      
     public List<Student_Family_Education_Income__c> getFamily(){   
         system.debug('44444');
        return [SELECT Name,Education_Level__c,Relationship_with_Student__c,Occupation__c,Monthly_Income__c FROM Student_Family_Education_Income__c  WHERE Student_Name__c = :qstr ORDER BY name];
    }
      
    public Student_Counselling_Attributes__c getstudentcounsel(){  
        system.debug('5555');
        studentcounsel= [SELECT Name, Childs_Interest__c, Parents_Interest__c, Travel_For_Education__c, Extra_Curricular_Activities__c,Role_Model__c,Family_Funding_Education_Method__c,Family_Open_to_meeting_to_understand_Ed__c,Family_Understand_Cost_of_Hr_Ed__c,Family_Understand_Hr_Ed_Options__c,Highest_Ed_Level_in_Family__c,Holland_Code__c,Relatives_who_can_fund_education__c FROM Student_Counselling_Attributes__c WHERE Student_Name__c = :qstr ORDER BY name];
         return studentcounsel;
    }
  

}

VisualForce Page 1:
 
<apex:page controller="StudentProfileListViewTest" title="Students Record" sidebar="false" docType="html-5.0">
    
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
    <apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="{!URLFOR($Resource.SLDS0120, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

    <apex:form >
 <div class="slds" style="margin-bottom:100px">
        <div id="header">
           Students Record
        </div>
         
        <br/>
        <br/>        
        <table>
            <tr>
                <td > <apex:inputText id="text-input-01" value="{!StudentName}" html-placeholder="Enter Student Name" /></td> 
                
                <td >
              
                             	<apex:selectList value="{!Year}" size="1"> 
                    				   <apex:selectOptions value="{!AcademicYear}"  />
          						</apex:selectList>

            </td>
             <!--   <td >   <apex:selectList value="{!School}" size="1"> 
                    				<apex:selectOptions value="{!SchoolName}" />
          						</apex:selectList></td> -->
               
                  <td >  <apex:commandButton value="Go!" action="{!search_method}"    /></td>   
            </tr>
        </table>
     <br/>
     <br/>
     
      <table class="slds-table slds-table--bordered profilelisting">
      
                <thead>
                    <tr class="slds-text-heading--label">
                       
                        <th scope="col" width="12%">
                           Studnet ID   </th>
                        <th scope="col"   width="12%"   >
                          Student Name
                      </th>
                      <th  scope="col" width="12%"  >
                           Academic Year
                      </th>
                        <th  scope="col" width="12%"  >
                          Class
                      </th>
                        <th scope="col" width="12%">
                           School   </th>
                        <th scope="col"   width="12%"   >
                          City
                      </th>
                      <th  scope="col" width="12%"  >
                          State
                      </th>
                       </tr>
                </thead>
                
                <tbody>    
                        
                     <apex:repeat value="{!StudDetail}" var="StDetail" >
                        <tr>
                            <td>  <apex:commandLink  action="{!StudPage}" style="text-align:center;">
                                {!StDetail.Student_Name__r.Name}
                                <apex:param name="StudId" value="{!StDetail.Student_Name__c}" assignTo="{!StudId}"/></apex:commandLink>                                            
                          
                            </td>
                           <td > {!StDetail.Student_Name__r.Student_First_Name__c} {!StDetail.Student_Name__r.Student_Last_Name__c}</td>
                       <td > {!StDetail.Year__c}</td>
                        <td > {!StDetail.Name}</td>     
                           <td > {!StDetail.School_Name__r.School_Name__c }</td>
                       <td > {!StDetail.Student_Name__r.City__c}</td>
                            <td > {!StDetail.Student_Name__r.State__c}</td>
                           </tr>
                            </apex:repeat>
                                       
                       </tbody>
                                              
        </table>
        
  
            
        </div>
    </apex:form>
    </html>
</apex:page>

VisualForce Page 2:
 
<apex:page controller="StudentProfileListViewTest" showHeader="true" sidebar="false" standardStylesheets="true" docType="html-5.0">
    
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
    <apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
   
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <apex:stylesheet value="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css"/>

    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<apex:form >
  
 <!-- REQUIRED SLDS WRAPPER -->
    <div class="slds" style="margin-bottom:100px;width:100%">
        <div id="header">
                     Student Profile Summary
         </div>
        <br/>       <!--LIST OUT ALL THE Students Academic Performance -->
  <apex:variable var="ctrcnt" value="{!1}"  />                    
  <apex:repeat value="{!Stud}" var="student">     
         
       
             <div id="card">
               <apex:outputPanel rendered="{!ctrcnt==1}" >
                 
                     
                   <div class="slds-card__body slds-text-align--center">
                        <div class="slds-tile">
                        <p class="slds-truncate">
               <b>Student Name:</b> {!studentrec.Student_First_Name__c} {!studentrec.Student_Last_Name__c}
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Student Class:</b> {!student.Name} <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Year: </b> {!student.Year__c}<br/>
               <b> Caste:</b> {!studentrec.Student_Caste__c} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b> Medium:</b> {!student.Medium_of_Instruction__c} <br/>
               </p>
               </div>
               
                </div>
                
            </apex:outputPanel>
           <apex:variable value="{!ctrcnt+1}" var="ctrcnt"/>  <!--increment-->
           </div>

<div  class="slds-card1" >
     <div class="slds-card__body">
         
        <table class="slds-table slds-table--bordered profilelisting">
      
                <thead>
                    <tr class="slds-text-heading--label">
                       
                        <th scope="col" width="12%">
                           Subject                        </th>
                        <th scope="col"   width="12%" class="slds-is-sortable"  >
                           Prior Exam
                      </th>
                      <th  scope="col" width="12%" class="slds-is-sortable" >
                           Final Exam
                      </th>
                       </tr>
                </thead>
                
                <tbody>    
                        
                        <apex:repeat value="{!student.Student_Scores__r}" var="cont">
                        <tr>
                                                                         
                           <td class="slds-cell-shrink">  {!cont.Subject_Name__c}</td>
                           <td class="slds-cell-shrink"> {!cont.Second_Exam_Marks__c}</td>
                       <td class="slds-cell-shrink"> {!cont.Final_Exam_Marks__c}</td>
                           </tr>
                            </apex:repeat>
                                       
                       </tbody>
                                              
        </table>
    </div>
   
        </div>

       </apex:repeat> 
       <br/>
       <br/>
          <div  class="slds-card3" >
     <div class="slds-card__body3"> 
   <div id="header1"> Student's Family Details  </div> 
        <table class="slds-table slds-table--bordered1 profilelisting1">
            <thead>
                    <tr class="slds-text-heading--label">
                       
                        <th scope="col" width="12%">
                       Family Member Name                        </th>
                        <th scope="col" width="12%" class="slds-is-sortable"  >
                           Relationship
                      </th>
                      <th  scope="col" width="12%" class="slds-is-sortable" >
                         Monthly Income
                      </th>
                        
                        <th scope="col" width="12%" class="slds-is-sortable"  >
                           Education Level
                      </th>
                      <th  scope="col" width="12%" class="slds-is-sortable" >
                        Occupation
                      </th>
                       </tr>
                </thead>
              <tbody>    
                        
                        <apex:repeat value="{!Family}" var="student">
                        <tr>
                                                                         
                           <td class="slds-cell-shrink">  {!student.Name}</td>
                           <td class="slds-cell-shrink"> {!student.Relationship_with_Student__c}</td>
                       <td class="slds-cell-shrink"> {!student.Monthly_Income__c}</td>
                             <td class="slds-cell-shrink"> {!student.Education_Level__c}</td>
                       <td class="slds-cell-shrink"> {!student.Occupation__c}</td>
                           </tr>
                            </apex:repeat>
                                       
                       </tbody>
     
   
       </table>
              </div></div>
        <div  class="slds-card2" >
     <div class="slds-card__body2"> 
   
              <div id="header1"> Counselling Parameters </div>
        <div id="Counselling" width="200px" class="tablecontainer">
        <table id="Counselling" class="slds-table slds-table--bordered profilelisting" cellpadding="3px !important" >
            <tr>
                <td>Child's Interest</td><td> {!studentcounsel.Childs_Interest__c} </td>
                <td >Parent's Interest</td><td> {!studentcounsel.Parents_Interest__c}</td>
                </tr><tr>
                <td>Role Model</td><td> {!studentcounsel.Role_Model__c}</td>
                 <td>Holland Code</td><td>{!studentcounsel.Holland_Code__c}</td>
                 </tr>
                 <tr>
                <td>Travel For Education </td><td> {!studentcounsel.Travel_For_Education__c}</td>
                    <td>Extra Curricular</td><td>{!studentcounsel.Extra_Curricular_Activities__c}</td>
</tr><tr>
                                     
                        <td>Family Understand Higer Ed Options</td><td> {!studentcounsel.Family_Understand_Hr_Ed_Options__c}</td>

                     <td>Highest Ed Level in Family</td><td> {!studentcounsel.Highest_Ed_Level_in_Family__c}</td>
</tr><tr>
                          <td>Family Funding Education Method</td><td> {!studentcounsel.Family_Funding_Education_Method__c}</td>

                              <td>Family Open to Meet</td><td> {!studentcounsel.Family_Open_to_meeting_to_understand_Ed__c}</td>
</tr><tr>
                                  <td>Relatives who can fund Education</td><td> {!studentcounsel.Relatives_who_can_fund_education__c}</td>
<td></td><td></td></tr>
                   
                               </table>    
                               </div>   
         </div></div>
        
       </div>  
    
</apex:form>
    </html>
</apex:page>

Thanks
Sivapriyaa M S
Hi,

Can anyone please tell me the solution for duplicate value display in VisualForce page.

The SOQL query retrieve the correct output.But in VisualForce page ,it display the N-number of times of same output.

SOQL Output:
User-added image

VisualForce Page Output:(It display more than one times)
User-added image

Apex Controller:
 
public with sharing class CollegeCourseClassic {
    
    Public List <CSM_Courses_By_Colleges__c> courses{get;set;} 
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
   public List<String> listOfCourseName {get;set;}
	public List<String> listCollegeName {get;set;}
    public List<String> listDistrictName {get;set;}
  // the current sort direction. defaults to asc
 public string college{get;set;}
     public string course{get;set;}
    public string state{get;set;}
       public string level{get;set;}
     public string district{get;set;}
  // the current field to sort by. defaults to last name
 

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + 'limit 100'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public CollegeCourseClassic() {
      
   listOfCourseName = new List<String>();
        listCollegeName = new List<String>();
        listDistrictName = new List<String>();
        for(CSM_Courses_By_Colleges__c courseName: [select id,name from ICSM_Courses_By_Colleges__c ])
			listOfCourseName.add(courseName.name);
        for(CSM_COLLEGES__C clgname: [select id,College_Name__c from CSM_COLLEGES__C limit:500])
            listCollegeName.add(clgname.College_Name__c);
        for(CSM_COLLEGES__C distName: [select id, District__c from CSM_COLLEGES__C])
        	listDistrictName.add(distName.District__c);
    soql = 'Select id,name,College_UGC_Id__r.College_UGC_Id__c,College_UGC_Id__r.state__c,College_UGC_Id__r.College_Name__c,College_UGC_Id__r.District__c,College_UGC_Id__r.Name,College_UGC_Id__r.City_Town__c ,Course_Level__c,Degree_Conferred__c,Department__c,Student_Intake__c From CSM_Courses_By_Colleges__c';
   runQuery();
  }


 
  // runs the actual query
  public void runQuery() {

    try {
         System.debug(soql);
      courses = Database.query(soql +' limit 100');
       
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'+e));
    }

  }

  // runs the search with parameters passed via Javascript
  public void search_method() {

      
    soql = 'Select id,name,College_UGC_Id__r.College_UGC_Id__c,College_UGC_Id__r.state__c,College_UGC_Id__r.College_Name__c,College_UGC_Id__r.District__c,College_UGC_Id__r.Name,College_UGC_Id__r.City_Town__c ,Course_Level__c,Degree_Conferred__c,Department__c,Student_Intake__c From CSM_Courses_By_Colleges__c where College_UGC_Id__r.College_Name__c != null';
    if (!college.equals(''))
         System.debug('college'+college);
      soql += ' and College_UGC_Id__r.College_Name__c  LIKE \''+String.escapeSingleQuotes(college)+'%\'';
         

    if (!course.equals(''))
      soql += ' and name LIKE \''+String.escapeSingleQuotes(course)+'%\'';
    if (!district.equals(''))
      soql += ' and College_UGC_Id__r.District__c LIKE \''+String.escapeSingleQuotes(district)+'%\'';  
    if (!level.equals('select'))
      soql += ' and Course_Level__c LIKE \''+String.escapeSingleQuotes(level)+'%\'';
 	if (!state.equals('selectst'))
      soql += ' and College_UGC_Id__r.state__c LIKE \''+String.escapeSingleQuotes(State)+'%\'';
    
    // run the query again
    runQuery();


  }


     public List<SelectOption> getcourselevel() {
         list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = CSM_COURSES_BY_COLLEGES__c.Course_Level__c.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
         options.add(new SelectOption('select','--Select Course Level--')); 
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options;
}
    public List<selectoption> getStates()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = CSM_COLLEGES__c.State__c.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
        options.add(new SelectOption('selectst','--Select State--')); 
    for (Schema.PicklistEntry a : values) 
    {     
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 


}

}

VisualForcePage 
 
<apex:page controller="CollegeCourseClassic" title="College Courses" sidebar="false" docType="html-5.0">

    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
    <apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="{!URLFOR($Resource.SLDS0120, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<apex:form >
   <script>
        function ChangeMode(mode){
            if(mode=='Awardees'){
                document.getElementById('awardees').style.display = 'block';
                document.getElementById('applicants').style.display = 'none';
                initAwardeesTableSearch();
                ApplicantsTableSearhDestroy();
            }
            if(mode=='Applicants'){
                document.getElementById('awardees').style.display = 'none';
                document.getElementById('applicants').style.display = 'block';
                initApplicantsTableSearch();
                AwardeesTableSearchDestroy();
            }

            quickSearch("text-input-01");
        }
            </script> 

    <style>
        #header{
            font-size:24px !important;
            text-align:center;
            margin-bottom:16px;
            margin-top:16px;
        }
        .filterlist{
            width: 16%;
            float:right;
            font-size: 16px;
            margin-left: 1px;
            margin-right: 20px;
        }
        .orgnamefilter{
            width: 25%;
            float:right;
            font-size: 16px;
            margin-right: 10px;
        margin-left: 10px;
        
        }
         .orgnamefilter1{
            width: 25%;
            float:right;
            font-size: 16px;
            margin-right: 10px;
        margin-left: 200px;
        
        }
        .issueArealist {
            width: 15%;
            
        margin-right: 450px;
        

        }
        .issueArealist1 {
            width: 15%;
          
        margin-right: 100px;
        

        }
        .profilelisting{
            width:97%;
            margin-left:1%;
            margin-right:3%;
        }
        .profilelisting td{
            vertical-align:middle !important;
            font-size:12px;
        }
        .tablecontainer{
            position:relative;
            top:20px;
        }
        #select-01{
            height:36px;
            line-height:36px;
            cursor: pointer;
        }
        #select-issue-area{
            height:36px;
            line-height:36px;
            cursor: pointer;
        }
        .buttonclass{
            font-size:12px;
        }
        .logo{
            width:50px;
            margin-right:10px;
        }
        .redbutton{
            background-color:#89211B !important;
            white-space:nowrap;
            border-style:none !important;
            font-weight:normal !important;
        }
        .yellowbutton{
            background-color:#FAA418 !important;
            white-space:nowrap;
            color:#89211B !important;
            border-style:none !important;
            font-weight:normal !important;
        }
        .orangebutton{
            background-color:#F15323 !important;
            border-style:none !important;
            font-weight:normal !important;
        }
        .btn:hover{
            opacity:0.8;
        }
        .link{color:#89211B !important;}
        .link:hover{color:#F15323 !important;}
        .slds img {
            max-width: none !important;
        }
        .fa-star {
            color: #8C1D04;
        }
        .center{text-align:center;}
    </style>
    <script type="text/javascript">
    function changeMe(sel)
    {
      sel.style.color = "#000";              
    }
</script>
    <!-- REQUIRED SLDS WRAPPER -->
    <div class="slds" style="margin-bottom:100px">
        <div id="header">
           Find Colleges and Courses
        </div>
        <table>
            <tr>
                <td > <apex:inputText id="text-input-01" list="{!listCollegeName}" value="{!college}" html-placeholder="Enter College Name" /></td> 
                <td >
                                       
                        <apex:inputText id="text-input-02" list="{!listOfCourseName}" value="{!course}" html-placeholder="Enter Course Name"/> 
           
                
            </td>
                <td >
              
                             	<apex:selectList value="{!level}" size="1"> 
                    				   <apex:selectOptions value="{!courselevel}"  />
          						</apex:selectList>

            </td>
                <td >   <apex:selectList value="{!state}" size="1"> 
                    				<apex:selectOptions value="{!States}" />
          						</apex:selectList></td>
               <td> 
               <apex:inputText id="select-01" list="{!listDistrictName}" value="{!district}" html-placeholder="Enter District"/> </td> 
              <td >  <apex:commandButton value="Go!" action="{!search_method}"    /></td>       
            </tr>
        </table>
       <apex:outputPanel title="">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
        <div id="awardees" width="95%" class="tablecontainer">
        <table id="awardeesTable" class="slds-table slds-table--bordered profilelisting" cellpadding="3px !important">
                <thead>
                    <tr class="slds-text-heading--label">
                        <th onclick="simulateTHclick('1');" colspan="1" class="slds-is-sortable" scope="col" width="12%">
                            College Name
                            <button class="slds-button slds-button--icon-bare">
                                <svg aria-hidden="true" class="slds-button__icon slds-button__icon--small">
                                    <use xlink:href="{!URLFOR($Resource.SLDS0120, '/assets/icons/utility-sprite/svg/symbols.svg#arrowdown')}"></use>
                                </svg>
                                <span class="slds-assistive-text">Sort</span>
                            </button>
                        </th>
                        
                        <th width="10%" onclick="simulateTHclick('3');" class="slds-is-sortable slds-cell-wrap" scope="col">Distict
                            <button class="slds-button slds-button--icon-bare">
                                <svg aria-hidden="true" class="slds-button__icon slds-button__icon--small">
                                    <use xlink:href="{!URLFOR($Resource.SLDS0120, '/assets/icons/utility-sprite/svg/symbols.svg#arrowdown')}"></use>
                                </svg>
                                <span class="slds-assistive-text">Sort</span>
                            </button>
                        </th>
                        <th onclick="simulateTHclick('4');" width="10%" class="slds-is-sortable slds-cell-wrap" scope="col">
                            <apex:outputtext value="State" id="LastPublished"/>
                            <button class="slds-button slds-button--icon-bare">
                                <svg aria-hidden="true" class="slds-button__icon slds-button__icon--small">
                                    <use xlink:href="{!URLFOR($Resource.SLDS0120, '/assets/icons/utility-sprite/svg/symbols.svg#arrowdown')}"></use>
                                </svg>
                                <span class="slds-assistive-text">Sort</span>
                            </button>
                        </th>
                                </tr>
                    <tr style="display:none;">
                        <th column-valueAwd="0" scope="col">&nbsp;</th>
                        <th column-valueAwd="1" scope="col">&nbsp;</th>
                        <th column-valueAwd="2" scope="col">&nbsp;</th>
                                                                  </tr>
                </thead>
                <tbody>
                   <!--LIST OUT ALL THE colleges and courses-->
                    <!-- COllege Name with State and District -->
                   
                    <apex:repeat value="{!courses}" var="ccourse" >
                    <tr >
                        <td class="slds-cell-wrap">
                               {!ccourse.College_UGC_Id__r.College_Name__c}
                        </td>
                         <td class="slds-cell-shrink">  {!ccourse.College_UGC_Id__r.District__c}</td>
                         <td class="slds-cell-shrink">  {!ccourse.College_UGC_Id__r.state__c}</td> 
                       <!--  <td class="slds-cell-wrap">  {!ccourse.CSM_Courses_By_Colleges__c.Name}</td> -->
                     </tr>
                     <tr>
                     <td colspan ="3">
                         
                        <!-- List of   Course  display under college  -->
                       <table id="coursesTable" class="slds-table slds-table--bordered profilelisting" cellpadding="3px !important">
                       <apex:repeat value="{!courses}" var="cont">
                        <tr>
                           <td class="slds-cell-wrap">  {!cont.Name}</td> 
                            
                           <td class="slds-cell-wrap">  {!cont.Course_Level__c}</td>
                           <td class="slds-cell-shrink"> {!cont.Degree_Conferred__c}</td>
                          <td  class="slds-cell-shrink"> {!cont.Department__c}</td>
                          <td class="slds-cell-shrink">{!cont.Student_Intake__c}</td>
                        
                         </tr>
                              </apex:repeat>
                            </table> 
                          </td>              </tr>
                    </apex:repeat>
               </tbody>
        </table>
        </div>

           </div>
             

</apex:form>
    </html>
        
</apex:page>

Thanks,
Sivapriyaa M S


 
Hi,

Can anyone please tell what is the error and solution.

Scenario:
I need to update the distributor discount value in account,It will update the QuoteLineItem,Quote and Opportunity Product.

But It thrown an error as follows,

Error:Apex trigger DistributorDiscountChangeTrigger caused an unexpected exception, contact your administrator: DistributorDiscountChangeTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0QLi0000004XP1LGAW; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []: Trigger.DistributorDiscountChangeTrigger: line 66, column 1 

id- 0QLi0000004XP1LGAW --> Contains QuoteLineitem

Trigger Code:
trigger DistributorDiscountChangeTrigger on Account (after update) {
    
    Map<Id, Account> accByIds = new Map<Id, Account>();
    Map<Id, Account> accsByIds = new Map<Id, Account>();
    
    for ( Account acc: Trigger.NEW) {
        if ( acc.Distributor_Discount_Service__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Service__c || acc.Distributor_Discount_Product__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Product__c ) {
            accByIds.put( acc.Id, acc);
        }
    }

    if ( !accByIds.isEmpty() ) {
        
        Map<Id, Opportunity> oppByIds = new Map<Id,Opportunity>( [ SELECT Id, Distributor__c FROM Opportunity WHERE Distributor__c IN: accByIds.keySet() AND IsClosed = FALSE]);        
        List<OpportunityLineItem> oppProds = [ SELECT Id, Distributor_Discount_Product_HIDDEN__c,Distributor_Discount_Service_HIDDEN__c,Opportunity.Distributor__c, PricebookEntry.Product2.Family, Distributor_Discount_1__c, Opportunity.Distributor__r.Distributor_Discount_Service__c, Opportunity.Distributor__r.Distributor_Discount_Product__c FROM OpportunityLineItem WHERE OpportunityId IN: oppByIds.keySet()];
        List<QuoteLineItem> qlis = [ SELECT Id, Distributor_Discount_1__c, Quote.Opportunity.Distributor__c, PricebookEntry.Product2.Family, Quote.Opportunity.Distributor__r.Distributor_Discount_Service__c, Quote.Opportunity.Distributor__r.Distributor_Discount_Product__c FROM QuoteLineItem WHERE Quote.OpportunityId IN: oppByIds.keySet()];
        List<Quote> oppqt = [ SELECT Id, Distributor_Service_Discount_Temp__c,Opportunity.Distributor__c,Distributor_Product_Discount_Temp__c,Distributor__c FROM Quote WHERE Quote.OpportunityId IN: oppByIds.keySet()];
       
         for ( Quote qt: oppqt ) {
            if ( qt.Opportunity.Distributor__c == null ) {
                qt.Distributor_Product_Discount_Temp__c  = 0;
                qt.Distributor_Service_Discount_Temp__c=0;
                continue;
            }
            if ( qt.Opportunity.Distributor__c != null) {
                qt.Distributor_Product_Discount_Temp__c = accByIds.get( qt.Opportunity.Distributor__c ).Distributor_Discount_Product__c;
                 qt.Distributor_Service_Discount_Temp__c= accByIds.get( qt.Opportunity.Distributor__c ).Distributor_Discount_Service__c;
            }       
         }
        

        for ( QuoteLineItem qli: qlis ) {

            if ( qli.Quote.Opportunity.Distributor__c == null ) {
                qli.Distributor_Discount_1__c = 0;
                continue;
            }
            if ( qli.PricebookEntry.Product2.Family == 'Service') {
                qli.Distributor_Discount_1__c = accByIds.get(qli.Quote.Opportunity.Distributor__c).Distributor_Discount_Service__c;
            } else if ( qli.PricebookEntry.Product2.Family != 'Non-Discount' ) {
                qli.Distributor_Discount_1__c = accByIds.get(qli.Quote.Opportunity.Distributor__c).Distributor_Discount_Product__c;
            } else {
                qli.Distributor_Discount_1__c = 0;
            }
            
        }
        for ( OpportunityLineItem oli: oppProds ) {
            if ( oli.Opportunity.Distributor__c == null ) {
                oli.Distributor_Discount_1__c  = 0;
               oli.Distributor_Discount_Product_HIDDEN__c=0;
                oli.Distributor_Discount_Service_HIDDEN__c=0;
                continue;
            }
            if ( oli.PricebookEntry.Product2.Family == 'Service') {
                oli.Distributor_Discount_1__c = accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Service__c;
                oli.Distributor_Discount_Service_HIDDEN__c=accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Service__c;
            } else if ( oli.PricebookEntry.Product2.Family != 'Non-Discount' ) {
                oli.Distributor_Discount_1__c = accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Product__c;
                oli.Distributor_Discount_Product_HIDDEN__c=accByIds.get( oli.Opportunity.Distributor__c ).Distributor_Discount_Product__c;
            } else {
                oli.Distributor_Discount_1__c = 0;
            }
        }
        
        update oppqt;
        update qlis; // Error  indicates this line
        update oppProds;
      
            
        }
        
    

}

Thanks,
Sivapriyaa M S










 
Hi,
Created field in Account Object,
1.Distributor Discount Product

 Created formula field in Quote Object,
1.Distributor Product Discount

Scenario :
If i enter the values in account field, it automatically update in Quote Object  for  OPEN Opportunity . 

I Try the Code:(i dont know what have to give in ELSE part )
IF( !ISPICKVAL( Opportunity.StageName ,'6. Closed/Won - PO at Disti') || ISPICKVAL( Opportunity.StageName ,'Closed Lost') || ISPICKVAL( Opportunity.StageName ,'Closed Invalid') ,  Opportunity.Distributor__r.Distributor_Discount_Product__c,  )

Else part: It Contains the Last modified value(Distributor Discount Product )account object.

For Example:
1.I enter the Value for  Distributor Discount Product in account Object = 24
   It automatically update the value Distributor Product Discount in Quote Object (For Open Opportunity) =24

2.I again enter the Value for  Distributor Discount Product in account Object = 50
   It should not update the value Distributor Product Discount in Quote Object (For close Opportunity) =24 (Not 50) - I need Only Existing Value (24).

Thanks
Sivapriyaa M S
Hi,
I am getting error "common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType"
I share my code .please view and tell me the solution,

 I am getting error when i used recordSetVar="location" 
If  not, it shows the map but i could not zoom it and it struck.

VFP:
 
<apex:page sidebar="false" showheader="false" standardController="Loc__c" recordSetVar="location" extensions="VicinageFindNearby">
    
  
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
   
    <script type="text/javascript" 
        src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> 
        </script>
       
 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon,accts;
              
           
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VicinageFindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type == 'exception') {
                              
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                
                    lat = 51.096214;
                    lon = 3.683153;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat,lon,accts){
  
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
            
         
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/green.png'
            });
            
                        
        
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
           
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
          
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
           
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.City__c + '<br/>' + 
                    acct.Country__c + '<br/>' + 
                    acct.Zip_Code__c;
               
           
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
          
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Map__Latitude__s, 
                                   acct.Map__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
           
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
      
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
  
        <div id="map-canvas"></div>
    </body>
</apex:page>





Apex Controller:
global with sharing class VicinageFindNearby {
    public VicinageFindNearby(ApexPages.StandardController controller) {}
 
    @RemoteAction

    global static List<Loc__c> getNearby(String lat, String lon) {

        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '40.427305';
            lon = '3.696754';
        }
 
    
        String queryString =
            'SELECT Id, Name, Map__Longitude__s, Map__Latitude__s,State_Province__c,City__c,Zip_Code__c ' +
            'FROM Loc__c '+
            'WHERE DISTANCE(Map__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Map__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';
 
       
        return(database.Query(queryString));
    }
}



Thanks in Advances,
Sivapriyaa M S
Hi 
how to get the countryname instead of country code in vfp.
I need countryname alone from standard country and state picklist.
Pls view my code and tell me .
Thanks in advance
// APEX CODE
Public with sharing class SOSLController

{
 Public List<loc__c> location {get;set;} // location
    public String imageURL{get;set;} // display a image
 Public String searchStr{get;set;} // find a string
 private ApexPages.StandardController Controller;
private final Contact cnct;
    /* display a image -method*/
 public  SOSLController(ApexPages.StandardController Controller)
  {
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    } 
      
     this.cnct = (Contact)controller.getRecord();
  }
    
    /* find a string and  run the sosl query*/
  Public void soslDemo_method(){
   location = New List<loc__c>();
 
    system.debug('inside sosl method');
    system.debug('country is'+cnct.MailingCountry );
    system.debug('state is'+cnct.MailingState);
 //  if(searchStr.length() > 1){
//  // String searchStr1 = searchStr;
    
      // String searchQuery = 'FIND \'' + state + '\' IN ALL FIELDS RETURNING  loc__c(Comp__c, Type__c,Client__c, Competitor__c,Event_Name__c, evt_Des__c , Dt_Ti__c, Ct_person__c,Ph_Num__c )';
       location  = [SELECT Comp__c, Client__c, Competitor__c, Type__c, Event_Name__c, evt_Des__c, Address1__c, Address2__c, City__c, Country__c, State_Province__c, Zip_Code__c, Dt_Ti__c, Ct_person__c, Ph_Num__c FROM loc__c WHERE State_Code__c =:cnct.MailingStateCode ];
   //   List<List <sObject>> searchList = search.query(searchQuery);
   //location = ((List<loc__c>)searchList[0]);
       /* Message */
  /* if(location.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, Type the location correctly or There is no details of the requested location found'));
       return;
   }
   
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter the location..'));
   return;
  }*/
  
}
}
VFP;
<apex:page standardController="Contact"  extensions="SOSLController"  sidebar="false" showHeader="false">
  <apex:form >
       <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Enter a location" id="acct1">
        
          <apex:outputLabel value="Country" />
       
          
          <apex:inputField value="{!contact.MailingCountryCode}" />
            <apex:outputLabel value="State" />
         
      
          <apex:inputField value="{!contact.MailingStateCode}" />
         
    <apex:commandButton value="Submit" action="{!soslDemo_method}"  reRender="acct,error,acct1" />
    <apex:outputPanel title="" id="error">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
  </apex:pageBlock>
    <apex:pageBlock title="Details of technical events" id="acct">
    <apex:pageblockTable value="{!location }" var="acc">
      
          <apex:column value="{!acc.Comp__c}"/>
         <apex:column value="{!acc.Type__c}"/>
          <apex:column value="{!acc.Client__c}"/>
        <apex:column value="{!acc.Competitor__c}"/>
        <apex:column value="{!acc.Event_Name__c}"/>
          <apex:column value="{!acc.evt_Des__c}"/>
        <apex:column value="{!acc.Address1__c}"/>
        <apex:column value="{!acc.Address2__c}"/>
        <apex:column value="{!acc.City__c}"/>
        <apex:column value="{!acc.Country__c}"/>
        <apex:column value="{!acc.State_Province__c}"/>
        <apex:column value="{!acc.Zip_Code__c}"/>
          <apex:column value="{!acc.Dt_Ti__c}"/>
        <apex:column value="{!acc.Ct_Person__c}"/>
          <apex:column value="{!acc.Ph_Num__c}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks 
Sivapriyaa M S
 
Hi,
I could not connect the salesforce for outlook.It shows that,"you are not connect to microsoft  exchange server"
User-added image
if anybody know tell me

Thanks and regards,
Sivapriyaa M S
Hi everyone,
I have doubt on leads sharing button.

i added sharing button in leads page layout  (Salesforce1)
User-added image
But I cannot see that sharing button in Salesforce1 App.
How to get that sharing button in salesforce1 App.
If anybody know tell me.

Thanks and Regards,
Sivapriyaa M S


 
Hi everyone,
My scenario  is,
 I have to create a reminder (using Workflow) for leads fields  to send via email .For that i have to create  email template according to Leads fields (E.g : Lead Status, Lead Source , name etc.,) 

Reminder is triggred when  the  reminder field (Customized field) is achieved .

If anybody know please tell me .

Thanks and Regards,
Sivapriyaa M S
 
Hi everyone,
 I have a doubt on "How to share the particular lead records to other users or group?" .Please let me know . Is there any possibility to share the particular lead records
Eg: I create a Lead "Betty".I have to share this to my group "QB".
What are the steps to share the lead.

Thanks in advance
Sivapriyaa.M.S
Hi  everyone,

I am getting error "Unknown property 'SearchController.Loc__c' " in VisualForce Page.Please review the code .
Let me know where i did mistake.

Thanks in advance

Apex Code :

public with sharing class SearchController {
  private String soql {get;set;}
  public List<Loc__c> Searchlocation {get;set;}
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
  public String sortField {
    get  { if (sortField == null) {sortField = 'location'; } return sortField;  }
    set;
  }
  public void runQuery() {
    try {
      Searchlocation = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }}
  public PageReference runSearch() {
    String location = Apexpages.currentPage().getParameters().get('location');
    soql = 'select  Comp__c,Client__c, Competitor__c, Type__c,Event_Name__c, Et_Desc__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c, from loc__C where loc__c != null';
    runQuery();
    return null;
  }
}

VF Code:

<apex:page controller="SearchController" sidebar="false">
  <apex:form >
  <apex:pageBlock title=" Find a Location" mode="edit">

  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("location").value,
          
          );
      }
      </script> 
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results">
          <apex:param name="location" value="" />
      </apex:actionFunction>

      <table cellpadding="1" cellspacing="1">
      <tr>
        <td style="font-weight:bold;">Location<br/>
        <input type="text" id="location" onkeyup="doSearch();"/>
        </td>
      </tr>        
      </table>
      </apex:pageBlock>
    </td>
    <td valign="top">
    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{! Loc__c}" var="location">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Company Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Comp__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Comp__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Client Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Client__C" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Client__C}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Competitor Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Competitor__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Competitor__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Type" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Type__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Event Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Event_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Event_Name__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Event Description" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Event_Desc__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Event_Desc__c}"/>
            </apex:column>
              <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Date and Time" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Dt_Ti__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Dt_Ti__c}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Contact Person" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Ct_person__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Ct_person__c}"/>
            </apex:column>
              <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Phone Number" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Ph_Num__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Ph_Num__c}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
    </td>
  </tr>
  </table>
  </apex:pageBlock>
  </apex:form>
</apex:page>  
Hi Everyone,

Requirenment: Every user should recall the approval process.

I follow this link for email service - https://salesforce.stackexchange.com/questions/122989/recall-approval-process-from-apex-for-non-admin-profile

I configured the email service and wrote the apex classes also ( code as below)
 
global class RecallEmailServiceNST implements Messaging.InboundEmailHandler 
{
    public RecallEmailServiceNST(ApexPages.StandardController controller){}
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope envelope)
    {  
        Messaging.InboundEmailResult emailresult = new Messaging.InboundEmailResult();
        system.debug(email.plainTextBody);
        if(email.subject.containsIgnoreCase('Recall NST'))
        {
            String str = email.subject.normalizeSpace();
            String NSTNumber = str.substring(str.indexOf('-')+1,str.length());
            System.debug('NSTNumber :'+NSTNumber);            
            NST__c con = [Select Id,Name From NST__c WHERE Name=:NSTNumber];
            try
            {        
            List<ProcessInstance> pi = [SELECT Id FROM ProcessInstance WHERE TargetObjectId=:con.Id AND Status='Pending'];  
              System.debug('pi :'+pi );  
            if(pi.size()==0)
                return emailresult;
            List<ProcessInstanceWorkitem> piw = [SELECT Id,ActorId,ProcessInstanceId FROM ProcessInstanceWorkitem WHERE Actor.Email=:email.fromAddress and ProcessInstanceId=:pi[0].Id];            
           System.debug('piw :'+piw ); 
            if(piw.size()==0)
                return emailresult;
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();                        
      /*      if(email.plainTextBody.containsIgnoreCase('<approved>'))
            {
                req.setComments('Request Approved by Email Approval..!!');
                req.setAction('Approve');
            }                                    
            else if(email.plainTextBody.containsIgnoreCase('<rejected>'))
            {
                req.setComments('Request Rejected by Email Approval..!!');
                req.setAction('Reject');
            }
            else */if(email.plainTextBody.containsIgnoreCase('<recalled>'))
            {
                req.setComments('Request Recalled by Email Approval..!!');
                 System.debug('Request Recalled by Email Approval..!!' ); 

                req.setAction('Removed');        
                 System.debug('Removed' ); 
            }
            req.setWorkitemId(piw[0].Id);                                  
            Approval.ProcessResult result = Approval.process(req);
            FeedItem a = new FeedItem(ParentId=con.Id,Type='TextPost');  
            if(result.isSuccess())                                    
            {
                a.Body='Email received from Approver and the process was '+result.getInstanceStatus();                
            }
            else if(!result.isSuccess())
            {
                a.Body='Email received from Approver but some error occured, please contact sys admin';
            }
            a.Body+=email.plainTextBody;
            Insert a;
            }
            catch(Exception e)
            {
                system.debug(e);
            }            
        }
        return emailresult;       
    } 
}

Error: 
A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

>>> recallemailservicenst@y-1sgjk0kf5kumx9gjf0ri0ajl9jp654aldvztnd1l5a4q
>>> vbjq7y.0q-cuhyeas.cs64.apex.sandbox.salesforce.com (Undelivered): 
>>> 550 An internal error occured

couls you please assist us to fix the internal server error.

Thanks
sivapriyaa  M S
Hi,

Can we replicate the ability to select multiple Files from computer and mass upload the Files? Using a Custom Button on Visualforce Page. 

Thanks,
Madhav G.
Hi All, 
Can any one tell how to Set USER ID + PWD + SECURITY TOKEN in sales force ORG. I am trying to login to saleforce from Heroko. Below is the screen I am looking for.

USER NAME -- ABC
PASSWORD --  XYZ
SECURITY TOKEN -- SALESFORCE SECURITY TOKEN

Not able to Post original screenshot but original screen shot is like this only. Please share how to go to this screen. If any information is missed out do let me know.
Thanks
Hi Everyone,

Requirenment: Every user should recall the approval process.

I follow this link for email service - https://salesforce.stackexchange.com/questions/122989/recall-approval-process-from-apex-for-non-admin-profile

I configured the email service and wrote the apex classes also ( code as below)
 
global class RecallEmailServiceNST implements Messaging.InboundEmailHandler 
{
    public RecallEmailServiceNST(ApexPages.StandardController controller){}
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,Messaging.InboundEnvelope envelope)
    {  
        Messaging.InboundEmailResult emailresult = new Messaging.InboundEmailResult();
        system.debug(email.plainTextBody);
        if(email.subject.containsIgnoreCase('Recall NST'))
        {
            String str = email.subject.normalizeSpace();
            String NSTNumber = str.substring(str.indexOf('-')+1,str.length());
            System.debug('NSTNumber :'+NSTNumber);            
            NST__c con = [Select Id,Name From NST__c WHERE Name=:NSTNumber];
            try
            {        
            List<ProcessInstance> pi = [SELECT Id FROM ProcessInstance WHERE TargetObjectId=:con.Id AND Status='Pending'];  
              System.debug('pi :'+pi );  
            if(pi.size()==0)
                return emailresult;
            List<ProcessInstanceWorkitem> piw = [SELECT Id,ActorId,ProcessInstanceId FROM ProcessInstanceWorkitem WHERE Actor.Email=:email.fromAddress and ProcessInstanceId=:pi[0].Id];            
           System.debug('piw :'+piw ); 
            if(piw.size()==0)
                return emailresult;
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();                        
      /*      if(email.plainTextBody.containsIgnoreCase('<approved>'))
            {
                req.setComments('Request Approved by Email Approval..!!');
                req.setAction('Approve');
            }                                    
            else if(email.plainTextBody.containsIgnoreCase('<rejected>'))
            {
                req.setComments('Request Rejected by Email Approval..!!');
                req.setAction('Reject');
            }
            else */if(email.plainTextBody.containsIgnoreCase('<recalled>'))
            {
                req.setComments('Request Recalled by Email Approval..!!');
                 System.debug('Request Recalled by Email Approval..!!' ); 

                req.setAction('Removed');        
                 System.debug('Removed' ); 
            }
            req.setWorkitemId(piw[0].Id);                                  
            Approval.ProcessResult result = Approval.process(req);
            FeedItem a = new FeedItem(ParentId=con.Id,Type='TextPost');  
            if(result.isSuccess())                                    
            {
                a.Body='Email received from Approver and the process was '+result.getInstanceStatus();                
            }
            else if(!result.isSuccess())
            {
                a.Body='Email received from Approver but some error occured, please contact sys admin';
            }
            a.Body+=email.plainTextBody;
            Insert a;
            }
            catch(Exception e)
            {
                system.debug(e);
            }            
        }
        return emailresult;       
    } 
}

Error: 
A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

>>> recallemailservicenst@y-1sgjk0kf5kumx9gjf0ri0ajl9jp654aldvztnd1l5a4q
>>> vbjq7y.0q-cuhyeas.cs64.apex.sandbox.salesforce.com (Undelivered): 
>>> 550 An internal error occured

couls you please assist us to fix the internal server error.

Thanks
sivapriyaa  M S
Hi all,

I am facing the "Apex CPU Time Limit Exceed Error"

When i am trying to attempt the account the APEX CPU Time limit exceed error occurs.

Could you please tell me why this error occur and how to fix this issue. Please let me know if you need additional information.

Following are the flow execution report and it shows only 4 opportunity record ids. 

Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 1 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0060H00000jhSDWQA2
myVariable_current = 0060H00000jhSDWQA2
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (0060H00000jhSDWQA2)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 1 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0060H00000jhXUbQAM
myVariable_current = 0060H00000jhXUbQAM
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (0060H00000jhXUbQAM)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 1 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0060H00000jhZ5HQAU
myVariable_current = 0060H00000jhZ5HQAU
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (0060H00000jhZ5HQAU)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Assign_Strategic_AMs_on_optys_tied_to_National_accounts
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label: Assign_Strategic_AMs_on_optys_tied_to_National_accounts-6_InterviewLabel
Current User: Tirumala Kuppani (005i0000007sBmw)
Start time: 10/24/2017 11:43 PM
Duration: 0 seconds
How the Interview Started
Tirumala Kuppani (005i0000007sBmw) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 006i000000aa4TcAAI
myVariable_current = 006i000000aa4TcAAI
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "10/24/2017 11:43 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Reseller__c} (null) Is null true
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Opportunity records where:
Id Equals {!myVariable_current.Id} (006i000000aa4TcAAI)
Update the records’ field values.
IsPrivate = false
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: Apex CPU time limit exceeded. For details, see API Exceptions.

Thanks in advance....

Regards,
Sivapriyaa M S
Hi Everyone,

I have faced the issue that the "DatedConversionObject" is not visible in Objects.

I have enable the "Multi-currency feature" in sandbox. I can access the object only via SOQL.

I dont know why the object is not visible in object after the "Multi-currency feature" is enabled in sandbox.

Is the object can only accessible via apex coding? or view it in Objects?

Could you please help me to fix the issue.

Thanks
Sivapriyaa M S
Hi,

Can anyone please tell me the solution for duplicate value display in VisualForce page.

The SOQL query retrieve the correct output.But in VisualForce page ,it display the N-number of times of same output.

SOQL Output:
User-added image

VisualForce Page Output:(It display more than one times)
User-added image

Apex Controller:
 
public with sharing class CollegeCourseClassic {
    
    Public List <CSM_Courses_By_Colleges__c> courses{get;set;} 
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
   public List<String> listOfCourseName {get;set;}
	public List<String> listCollegeName {get;set;}
    public List<String> listDistrictName {get;set;}
  // the current sort direction. defaults to asc
 public string college{get;set;}
     public string course{get;set;}
    public string state{get;set;}
       public string level{get;set;}
     public string district{get;set;}
  // the current field to sort by. defaults to last name
 

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + 'limit 100'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public CollegeCourseClassic() {
      
   listOfCourseName = new List<String>();
        listCollegeName = new List<String>();
        listDistrictName = new List<String>();
        for(CSM_Courses_By_Colleges__c courseName: [select id,name from ICSM_Courses_By_Colleges__c ])
			listOfCourseName.add(courseName.name);
        for(CSM_COLLEGES__C clgname: [select id,College_Name__c from CSM_COLLEGES__C limit:500])
            listCollegeName.add(clgname.College_Name__c);
        for(CSM_COLLEGES__C distName: [select id, District__c from CSM_COLLEGES__C])
        	listDistrictName.add(distName.District__c);
    soql = 'Select id,name,College_UGC_Id__r.College_UGC_Id__c,College_UGC_Id__r.state__c,College_UGC_Id__r.College_Name__c,College_UGC_Id__r.District__c,College_UGC_Id__r.Name,College_UGC_Id__r.City_Town__c ,Course_Level__c,Degree_Conferred__c,Department__c,Student_Intake__c From CSM_Courses_By_Colleges__c';
   runQuery();
  }


 
  // runs the actual query
  public void runQuery() {

    try {
         System.debug(soql);
      courses = Database.query(soql +' limit 100');
       
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'+e));
    }

  }

  // runs the search with parameters passed via Javascript
  public void search_method() {

      
    soql = 'Select id,name,College_UGC_Id__r.College_UGC_Id__c,College_UGC_Id__r.state__c,College_UGC_Id__r.College_Name__c,College_UGC_Id__r.District__c,College_UGC_Id__r.Name,College_UGC_Id__r.City_Town__c ,Course_Level__c,Degree_Conferred__c,Department__c,Student_Intake__c From CSM_Courses_By_Colleges__c where College_UGC_Id__r.College_Name__c != null';
    if (!college.equals(''))
         System.debug('college'+college);
      soql += ' and College_UGC_Id__r.College_Name__c  LIKE \''+String.escapeSingleQuotes(college)+'%\'';
         

    if (!course.equals(''))
      soql += ' and name LIKE \''+String.escapeSingleQuotes(course)+'%\'';
    if (!district.equals(''))
      soql += ' and College_UGC_Id__r.District__c LIKE \''+String.escapeSingleQuotes(district)+'%\'';  
    if (!level.equals('select'))
      soql += ' and Course_Level__c LIKE \''+String.escapeSingleQuotes(level)+'%\'';
 	if (!state.equals('selectst'))
      soql += ' and College_UGC_Id__r.state__c LIKE \''+String.escapeSingleQuotes(State)+'%\'';
    
    // run the query again
    runQuery();


  }


     public List<SelectOption> getcourselevel() {
         list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = CSM_COURSES_BY_COLLEGES__c.Course_Level__c.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
         options.add(new SelectOption('select','--Select Course Level--')); 
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options;
}
    public List<selectoption> getStates()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = CSM_COLLEGES__c.State__c.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
        options.add(new SelectOption('selectst','--Select State--')); 
    for (Schema.PicklistEntry a : values) 
    {     
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 


}

}

VisualForcePage 
 
<apex:page controller="CollegeCourseClassic" title="College Courses" sidebar="false" docType="html-5.0">

    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
    <apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="{!URLFOR($Resource.SLDS0120, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<apex:form >
   <script>
        function ChangeMode(mode){
            if(mode=='Awardees'){
                document.getElementById('awardees').style.display = 'block';
                document.getElementById('applicants').style.display = 'none';
                initAwardeesTableSearch();
                ApplicantsTableSearhDestroy();
            }
            if(mode=='Applicants'){
                document.getElementById('awardees').style.display = 'none';
                document.getElementById('applicants').style.display = 'block';
                initApplicantsTableSearch();
                AwardeesTableSearchDestroy();
            }

            quickSearch("text-input-01");
        }
            </script> 

    <style>
        #header{
            font-size:24px !important;
            text-align:center;
            margin-bottom:16px;
            margin-top:16px;
        }
        .filterlist{
            width: 16%;
            float:right;
            font-size: 16px;
            margin-left: 1px;
            margin-right: 20px;
        }
        .orgnamefilter{
            width: 25%;
            float:right;
            font-size: 16px;
            margin-right: 10px;
        margin-left: 10px;
        
        }
         .orgnamefilter1{
            width: 25%;
            float:right;
            font-size: 16px;
            margin-right: 10px;
        margin-left: 200px;
        
        }
        .issueArealist {
            width: 15%;
            
        margin-right: 450px;
        

        }
        .issueArealist1 {
            width: 15%;
          
        margin-right: 100px;
        

        }
        .profilelisting{
            width:97%;
            margin-left:1%;
            margin-right:3%;
        }
        .profilelisting td{
            vertical-align:middle !important;
            font-size:12px;
        }
        .tablecontainer{
            position:relative;
            top:20px;
        }
        #select-01{
            height:36px;
            line-height:36px;
            cursor: pointer;
        }
        #select-issue-area{
            height:36px;
            line-height:36px;
            cursor: pointer;
        }
        .buttonclass{
            font-size:12px;
        }
        .logo{
            width:50px;
            margin-right:10px;
        }
        .redbutton{
            background-color:#89211B !important;
            white-space:nowrap;
            border-style:none !important;
            font-weight:normal !important;
        }
        .yellowbutton{
            background-color:#FAA418 !important;
            white-space:nowrap;
            color:#89211B !important;
            border-style:none !important;
            font-weight:normal !important;
        }
        .orangebutton{
            background-color:#F15323 !important;
            border-style:none !important;
            font-weight:normal !important;
        }
        .btn:hover{
            opacity:0.8;
        }
        .link{color:#89211B !important;}
        .link:hover{color:#F15323 !important;}
        .slds img {
            max-width: none !important;
        }
        .fa-star {
            color: #8C1D04;
        }
        .center{text-align:center;}
    </style>
    <script type="text/javascript">
    function changeMe(sel)
    {
      sel.style.color = "#000";              
    }
</script>
    <!-- REQUIRED SLDS WRAPPER -->
    <div class="slds" style="margin-bottom:100px">
        <div id="header">
           Find Colleges and Courses
        </div>
        <table>
            <tr>
                <td > <apex:inputText id="text-input-01" list="{!listCollegeName}" value="{!college}" html-placeholder="Enter College Name" /></td> 
                <td >
                                       
                        <apex:inputText id="text-input-02" list="{!listOfCourseName}" value="{!course}" html-placeholder="Enter Course Name"/> 
           
                
            </td>
                <td >
              
                             	<apex:selectList value="{!level}" size="1"> 
                    				   <apex:selectOptions value="{!courselevel}"  />
          						</apex:selectList>

            </td>
                <td >   <apex:selectList value="{!state}" size="1"> 
                    				<apex:selectOptions value="{!States}" />
          						</apex:selectList></td>
               <td> 
               <apex:inputText id="select-01" list="{!listDistrictName}" value="{!district}" html-placeholder="Enter District"/> </td> 
              <td >  <apex:commandButton value="Go!" action="{!search_method}"    /></td>       
            </tr>
        </table>
       <apex:outputPanel title="">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
        <div id="awardees" width="95%" class="tablecontainer">
        <table id="awardeesTable" class="slds-table slds-table--bordered profilelisting" cellpadding="3px !important">
                <thead>
                    <tr class="slds-text-heading--label">
                        <th onclick="simulateTHclick('1');" colspan="1" class="slds-is-sortable" scope="col" width="12%">
                            College Name
                            <button class="slds-button slds-button--icon-bare">
                                <svg aria-hidden="true" class="slds-button__icon slds-button__icon--small">
                                    <use xlink:href="{!URLFOR($Resource.SLDS0120, '/assets/icons/utility-sprite/svg/symbols.svg#arrowdown')}"></use>
                                </svg>
                                <span class="slds-assistive-text">Sort</span>
                            </button>
                        </th>
                        
                        <th width="10%" onclick="simulateTHclick('3');" class="slds-is-sortable slds-cell-wrap" scope="col">Distict
                            <button class="slds-button slds-button--icon-bare">
                                <svg aria-hidden="true" class="slds-button__icon slds-button__icon--small">
                                    <use xlink:href="{!URLFOR($Resource.SLDS0120, '/assets/icons/utility-sprite/svg/symbols.svg#arrowdown')}"></use>
                                </svg>
                                <span class="slds-assistive-text">Sort</span>
                            </button>
                        </th>
                        <th onclick="simulateTHclick('4');" width="10%" class="slds-is-sortable slds-cell-wrap" scope="col">
                            <apex:outputtext value="State" id="LastPublished"/>
                            <button class="slds-button slds-button--icon-bare">
                                <svg aria-hidden="true" class="slds-button__icon slds-button__icon--small">
                                    <use xlink:href="{!URLFOR($Resource.SLDS0120, '/assets/icons/utility-sprite/svg/symbols.svg#arrowdown')}"></use>
                                </svg>
                                <span class="slds-assistive-text">Sort</span>
                            </button>
                        </th>
                                </tr>
                    <tr style="display:none;">
                        <th column-valueAwd="0" scope="col">&nbsp;</th>
                        <th column-valueAwd="1" scope="col">&nbsp;</th>
                        <th column-valueAwd="2" scope="col">&nbsp;</th>
                                                                  </tr>
                </thead>
                <tbody>
                   <!--LIST OUT ALL THE colleges and courses-->
                    <!-- COllege Name with State and District -->
                   
                    <apex:repeat value="{!courses}" var="ccourse" >
                    <tr >
                        <td class="slds-cell-wrap">
                               {!ccourse.College_UGC_Id__r.College_Name__c}
                        </td>
                         <td class="slds-cell-shrink">  {!ccourse.College_UGC_Id__r.District__c}</td>
                         <td class="slds-cell-shrink">  {!ccourse.College_UGC_Id__r.state__c}</td> 
                       <!--  <td class="slds-cell-wrap">  {!ccourse.CSM_Courses_By_Colleges__c.Name}</td> -->
                     </tr>
                     <tr>
                     <td colspan ="3">
                         
                        <!-- List of   Course  display under college  -->
                       <table id="coursesTable" class="slds-table slds-table--bordered profilelisting" cellpadding="3px !important">
                       <apex:repeat value="{!courses}" var="cont">
                        <tr>
                           <td class="slds-cell-wrap">  {!cont.Name}</td> 
                            
                           <td class="slds-cell-wrap">  {!cont.Course_Level__c}</td>
                           <td class="slds-cell-shrink"> {!cont.Degree_Conferred__c}</td>
                          <td  class="slds-cell-shrink"> {!cont.Department__c}</td>
                          <td class="slds-cell-shrink">{!cont.Student_Intake__c}</td>
                        
                         </tr>
                              </apex:repeat>
                            </table> 
                          </td>              </tr>
                    </apex:repeat>
               </tbody>
        </table>
        </div>

           </div>
             

</apex:form>
    </html>
        
</apex:page>

Thanks,
Sivapriyaa M S


 
Hi,
Created field in Account Object,
1.Distributor Discount Product

 Created formula field in Quote Object,
1.Distributor Product Discount

Scenario :
If i enter the values in account field, it automatically update in Quote Object  for  OPEN Opportunity . 

I Try the Code:(i dont know what have to give in ELSE part )
IF( !ISPICKVAL( Opportunity.StageName ,'6. Closed/Won - PO at Disti') || ISPICKVAL( Opportunity.StageName ,'Closed Lost') || ISPICKVAL( Opportunity.StageName ,'Closed Invalid') ,  Opportunity.Distributor__r.Distributor_Discount_Product__c,  )

Else part: It Contains the Last modified value(Distributor Discount Product )account object.

For Example:
1.I enter the Value for  Distributor Discount Product in account Object = 24
   It automatically update the value Distributor Product Discount in Quote Object (For Open Opportunity) =24

2.I again enter the Value for  Distributor Discount Product in account Object = 50
   It should not update the value Distributor Product Discount in Quote Object (For close Opportunity) =24 (Not 50) - I need Only Existing Value (24).

Thanks
Sivapriyaa M S
Hi everyone,
I have doubt on leads sharing button.

i added sharing button in leads page layout  (Salesforce1)
User-added image
But I cannot see that sharing button in Salesforce1 App.
How to get that sharing button in salesforce1 App.
If anybody know tell me.

Thanks and Regards,
Sivapriyaa M S


 
Hi  everyone,

I am getting error "Unknown property 'SearchController.Loc__c' " in VisualForce Page.Please review the code .
Let me know where i did mistake.

Thanks in advance

Apex Code :

public with sharing class SearchController {
  private String soql {get;set;}
  public List<Loc__c> Searchlocation {get;set;}
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
  public String sortField {
    get  { if (sortField == null) {sortField = 'location'; } return sortField;  }
    set;
  }
  public void runQuery() {
    try {
      Searchlocation = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }}
  public PageReference runSearch() {
    String location = Apexpages.currentPage().getParameters().get('location');
    soql = 'select  Comp__c,Client__c, Competitor__c, Type__c,Event_Name__c, Et_Desc__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c, from loc__C where loc__c != null';
    runQuery();
    return null;
  }
}

VF Code:

<apex:page controller="SearchController" sidebar="false">
  <apex:form >
  <apex:pageBlock title=" Find a Location" mode="edit">

  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("location").value,
          
          );
      }
      </script> 
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results">
          <apex:param name="location" value="" />
      </apex:actionFunction>

      <table cellpadding="1" cellspacing="1">
      <tr>
        <td style="font-weight:bold;">Location<br/>
        <input type="text" id="location" onkeyup="doSearch();"/>
        </td>
      </tr>        
      </table>
      </apex:pageBlock>
    </td>
    <td valign="top">
    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{! Loc__c}" var="location">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Company Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Comp__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Comp__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Client Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Client__C" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Client__C}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Competitor Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Competitor__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Competitor__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Type" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Type__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Event Name" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Event_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Event_Name__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Event Description" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Event_Desc__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Event_Desc__c}"/>
            </apex:column>
              <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Date and Time" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Dt_Ti__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Dt_Ti__c}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Contact Person" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Ct_person__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Ct_person__c}"/>
            </apex:column>
              <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Phone Number" action="{!toggleSort}" rerender="results">
                        <apex:param name="sortField" value="Ph_Num__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Loc__c.Ph_Num__c}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
    </td>
  </tr>
  </table>
  </apex:pageBlock>
  </apex:form>
</apex:page>