• <Saket>
  • NEWBIE
  • 299 Points
  • Member since 2017

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 65
    Replies
Where am i missing, please help ?

 public static ReturnTypeClass prepareReqWrapper(ReturnTypeClass reqWrap){      
        
        ReturnTypeClass reqWrapperNew = new ReturnTypeClass();

        system.debug('reqWrap'+reqWrap);        
        try{            
            ReturnTypeClass.AR_INV_INBND_STG_ROW objInputIns = reqWrap.DataArea.AR_INV_INBND_STG_ROW != null ? reqWrap.DataArea.AR_INV_INBND_STG_ROW : new ReturnTypeClass.AR_INV_INBND_STG_ROW();
            
            reqWrapperNew.DataArea.AR_INV_INBND_STG_ROW.AMOUNT = objInputIns.AMOUNT != null ? objInputIns.AMOUNT : '0';
            }
            catch(Exception e){
            
            }
            return reqWrapperNew;
            
            
My 'ReturnTypeClass' is - 

global class ReturnTypeClass {

    public class DataArea {
        public AR_INV_INBND_STG_ROW AR_INV_INBND_STG_ROW;
    }

    public class AR_INV_INBND_STG_ROW {
        public String AMOUNT;
    }
}
           
New to Apex...

Whenever a Task is created, I'd like to relate the Task's WhatID to the related Contact's (whoid) lookup field (custom field) TriggerTest__c. 

I have been receivin this error message : Error: Compile Error: Cannot save a trigger during a parse and save class call at line -1 column -1
 
trigger TaskRelatedToContact on Task (after insert,after update) {


Set<Id> ContactIds = new Set<Id>(); for(Task t : trigger.new)
{String wId = t.WhoId; 
if(wId!=null && wId.startsWith('003') && 
   !ContactIds.contains(t.WhoId)) 
    
    { ContactIds.add(t.WhoId); } }


List<Contact> 
taskContacts = [Select Id, TriggerTest__c 
from Contact where Id in :ContactIds]; 
Map<Id, Contact> ContactMap = new Map<Id, Contact>(); 
for(CONTACT c : taskContacts)
{ ContactMap.put(c.Id,c); } 


for(Task t : trigger.new){ String wId = t.WhoId; 
if(wId!=null && wId.startswith('003')){CONTACT thisContact = ContactMap.get(t.WhoId); 
if(thisContact!=null){t.WhatId = thiscontact.TriggerTest__c;} 
} 
} 
}

 
  • April 24, 2018
  • Like
  • 0
I have created a visualforce component and would like to use $Action.object name.action name($Action.Contact.Del) within it but i am getting the above error. Following is my controller and component code:
Component code
<apex:component controller ="PaginationForComponent">
    <apex:attribute name= "objectName" description = "The object's name" type = "String" required = "true" assignTo="{!objName}"/>
    <apex:attribute name= "fieldName" description = "Fields to be displayed" type = "String" required ="true" assignTo="{!fieldNames}"/>
<apex:outputLink value="{!URLFOR($Action."{!objName}".Edit,contacts.con.id)}"> 
                        Edit |
                    </apex:outputlink>
                    <apex:outputLink value="{!URLFOR($Action."{!objName}".Delete,contacts.con.id)}"> 
                        Del |
                    </apex:outputlink>

Controller code:
public class PaginationForComponent {
public String objName{get;set;}
	public String fieldNames{get;set;}
}

Ps: Only relevant code is provided here​
String objName = 'Contact';
string alphaSearchConct = 'A';
String fieldNames = 'name,id';
list<sObject> ct = Database.query('SELECT '+ fieldNames +'FROM '+ objName +'WHERE lastname Like:'+alphaSearchConct +'%');

 
Hi All,

I nedd Rollup summery on Case object using trigger . pleae help me.
public class OrgRestDemoController2 {

   

           public static void submit() {

HttpRequest request = new HttpRequest();
request.setEndpoint('http://.sfdkcimmmn.com/api/responsexxx');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
string Str ='{"Name": "ddu","Type": "xxx", "PayFrequency": "0R1jIbo/lZquTYoMRtljVw=="}';
        
request.setBody(str);
//request.setCompressed(true);
Http http = new Http();
HTTPResponse response = http.send(request);
// Parse the JSON response

if (response.getStatusCode() != 200) {
    System.debug('The status code returned was not expected: ' +
                 response.getStatusCode() + ' ' + response.getStatus());

else  
{
    System.debug(response.getBody());
}
}
}
===============================================================
<apex:page controller="OrgRestDemoController2" showHeader="false">


<apex:form >
<apex:pageBlock >

<apex:pageBlockButtons >
<apex:commandButton action="{!submit}" value="submit" />
</apex:pageBlockButtons>

</apex:pageBlock>

</apex:form>


on clicking on submit button, iam not getting the blank page,,,,, bt in anonymous window it got executed,, may in know my method is correct or wrng please...or i should use page reference method instead of the submit??? can please rewrite the code ..to executeit thanks in advance...
Hi Guys,

this is my code :
public class CreateMultiExtraBoost {

	public List<cBoost> boostList {get; set;}
    Integer listSize {get;set;}
    public Id opportunityId {get;set;}
    public ID finalBoostId {get; set;}
        
    // Constructor 
    public CreateMultiExtraBoost (){
    	opportunityId =  ApexPages.currentPage().getparameters().get('oppId');
    }

	//Methode
	public List<cBoost> getBoosts() {
		if(boostList == null) {
			boostList = new List<cBoost>();
			for(FinalBoost__c c: [select Id, Name from FinalBoost__c ]) {
				boostList.add(new cBoost(c));
			}
		}
		return boostList;
	}

	public PageReference save() {
 
		List<FinalBoost__c> selectedContacts = new List <FinalBoost__c>();
        List<BoostOpp__c> boostItems = new List <BoostOpp__c>(); 
        pagereference oppPage = new pagereference('/' + opportunityId);

		for(cBoost cCon: getBoosts ()) {
			if(cCon.selected == true ) {
				selectedContacts.add(cCon.con);
			}
		}

		System.debug('These are the selected ...');
		for(FinalBoost__c con: selectedContacts) {
			system.debug(con);
		}
        
        for (FinalBoost__c con: selectedContacts) {
            	boostItems.add(new BoostOpp__c());
            	finalBoostId = con.Id;
            
            		for(BoostOpp__c boostIteminList : boostItems) {
                        boostIteminList.Opportunity__c = opportunityId;
                        boostIteminList.FinalBoost__c = finalBoostId;
       	 }
       }
        insert boostItems;
        return oppPage;
	}
    
   
   // WrapperClass
	public class cBoost {
		public FinalBoost__c con {get; set;}
		public Boolean selected {get; set;}

		// Constructor 
        public cBoost(FinalBoost__c c) {
			con = c;
			selected = false;
		}
	}
}

A visualforcepage shows the table of FinalBoost records. I can select records and use them in the save methode.  The BoostOpp__c object is a junction object. It is related to the opportunity and the FinalBoost Object. 

In my loop, i want to create for each selected record one child record and assign the parent id (FinalBoost) to the masterDetail field. At the moment, it creates for each selection one record but allways with the same finalBoostId.  Is there a simple solution for that ? 


Cheers Sandra
Hi All,

I have a scenario as showing all fields from an object in a visualforce page dynamically. That is I want to pull all the fields and put it in <apex:inputfield> component for creating a record from that page.
But If I am creating a field in that particular object which should be added automatically without changing the code.

Thanks,
Rakshana
Hi Team,

How to redirect the custom vf page to custom object after clicking on Cancel button?
public with sharing class HighRiskSuccessFactorsCls {
    
    public High_Risk_Success_Factors__c hrsf {get;set;}
    ApexPages.StandardController con;
    public HighRiskSuccessFactorsCls(ApexPages.StandardController sc){
        con=sc;
    }
    
    public PageReference saveNew()
     { 
         PageReference pr; 
         try{ con.save();
         Schema.DescribeSObjectResult describeResult = con.getRecord().getSObjectType().getDescribe();
         pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e');
         pr.setRedirect(true);
         return pr;
         }catch(Exception e){ 
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
         return null; }
     
     }
    Public PageReference doCancel(){
        PageReference pageRef = new PageReference('/apex/High_Risk_Success_Factors__c?id='+hrsf.id+'&Sfdc.override=1');
    	pageRef.getParameters().put('tab','High Risk Success Factors');
    	return pageRef;	
    }

}
Please let me know how can i redirect to custom object tab.

Thanks.
Lakshmi
 
Hi,

i am new to salesforce and i have a scenario where i have an object Search_Filter__c where i want to insert records based on the account.
if any account has 10 address it should create multiple records with the unique city value populated in that in the Search_Filter__c. like if there are two cties with the same name, it should create 1 record else two

i have written the code as:

trigger RcordInsert on Account (after insert, after update) {

map<id,account> mapAcc= new map<id,account>();
set<string> cities = new set<string>();

for(account acc: trigger.new){
    if(acc.KOL_Set_Search_flag__c != null){
        mapAcc.put(acc.id,acc);
        system.debug('id is'+mapAcc);
    }
}

list<account> listSearch = new list<account>([ SELECT name,
                                                      KOL_Set_Search_flag__c,
                                                      Middle_vod__c,
                                                      LastName,
                                                      (select City_vod__c,State_vod__c,Country_olr__c,Zip_vod__c from Address_vod__r )
                                               FROM account 
                                               WHERE id in : mapAcc.keyset()
                                            ]);
                                               
        list<Search_Filter__c> searchUpdateList  = new list<GBI_Search_Filter__c>();                                                                      
     for(account c : listSearch ){
      
  if(c.KOL_Set_Search_flag__c == true){
            KOL_GBI_Search_Filter__c searchFilter = new KOL_GBI_Search_Filter__c();
                searchFilter.KOL_FIRSTNAME__c   =  c.name;
                searchFilter.KOL_ID__c = c.id;
                searchFilter.KOL_MIDDLENAME__c  =  c.Middle_vod__c;
                searchFilter.KOL_LASTNAME__c    =  c.LastName;
               // For(Integer I = 0; I < c.Address_vod__r.size(); I++){
                for(Address_vod__c addr : c.Address_vod__r ){
                   
                searchFilter.KOL_CITY__c   =  addr.City_vod__c;
                searchFilter.KOL_STATE__c   =  addr.State_vod__c;
                searchFilter.KOL_POSTAL_ZIP_CODE__c   =  addr.Zip_vod__c;
                searchFilter.KOL_COUNTRY__c   =  addr.Country_olr__c;
                
               }
               
                searchUpdateList.add(searchFilter);
        }
        
     }     
     
     insert searchUpdateList;                                                                    
}

Thanks in advance
I am creating a custom generic Look Up Visualforce Component from Lightning SLDS using Angular JS. The problem I am facing is when I am calling component multiple times in one visual force page it's not working properly. calling single time working perfectly. I also take care of rendering js, for example, function name I appended a unique number which is passed from VF directly so all the function which is getting rendered is unique which you call component time in a page.

Please suggest me a solution.

Thanks 
Saket Sharma
Hi There,

I would like to know is there any possibility to restrict users from creating more than a single opportunity per day by per person on Acount object?

Thanks
Syed
Where am i missing, please help ?

 public static ReturnTypeClass prepareReqWrapper(ReturnTypeClass reqWrap){      
        
        ReturnTypeClass reqWrapperNew = new ReturnTypeClass();

        system.debug('reqWrap'+reqWrap);        
        try{            
            ReturnTypeClass.AR_INV_INBND_STG_ROW objInputIns = reqWrap.DataArea.AR_INV_INBND_STG_ROW != null ? reqWrap.DataArea.AR_INV_INBND_STG_ROW : new ReturnTypeClass.AR_INV_INBND_STG_ROW();
            
            reqWrapperNew.DataArea.AR_INV_INBND_STG_ROW.AMOUNT = objInputIns.AMOUNT != null ? objInputIns.AMOUNT : '0';
            }
            catch(Exception e){
            
            }
            return reqWrapperNew;
            
            
My 'ReturnTypeClass' is - 

global class ReturnTypeClass {

    public class DataArea {
        public AR_INV_INBND_STG_ROW AR_INV_INBND_STG_ROW;
    }

    public class AR_INV_INBND_STG_ROW {
        public String AMOUNT;
    }
}
           


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><p889:basicChecksDetailsResponse xmlns:p889="http://comexp.ibm.com"><basicChecksDetailsReturn>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;ExportEROData xmlns=&quot;http://w3.test.com/xmlns/ibmww/ff/sdf/ews/erodata&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://w3.test.com/xmlns/testww/ff/sdf/ews/erodata https://w3-206-beta1.w3-gslbdst.test.com/isc/esd/ibmexpws/schemas/ExportEROData_0101.xsd&quot;&gt;
    &lt;ExportChecksPassed&gt;true&lt;/ExportChecksPassed&gt;
    &lt;ExportUnderReview&gt;false&lt;/ExportUnderReview&gt;
    &lt;ExportLocations&gt;
        &lt;ExportLocationPassed&gt;US&lt;/ExportLocationPassed&gt;
    &lt;/ExportLocations&gt;
&lt;/ExportEROData&gt;
</basicChecksDetailsReturn></p889:basicChecksDetailsResponse></soapenv:Body></soapenv:Envelope>
I need "ExportChecksPassed" ,"ExportUnderReview" values 
what is the advantages of querying data withing the for loop itself like below

for(Account a:[select name from Account])
{
***logic***
}
Hi Team,

Requirement : I have created custom vf page for showing detailed record. Form here i have created custom clone button. I want to clone the record from detail page and i need to edit the fields as our own details (not existing record details) and create a new record.
How can we write additional vf page and controller class for cloning functionality.
Note : After clicking on clone button that page redirected to another page and show the record details, if i click on cancel button no need to create new record, until clicking on save button.

Please let me know any one , how can we achieve this functionality........


Thanks in Advance!....
Lakshmi.
 
I have a wrapper class that i want to display on a visualforce page using repeat tag. Following is my code 
public class PaginationForComponent {
    public String objName{get;set;}
	public String[] fieldNames{get;set;}
	list<sObject> con = new list<sObject>();

	
	public PaginationForComponent(){
		RecordsPerPageslist = 10;
	}

	public String query;
	public String alphaSearchConct{get;set;}
	public string msg {get;set;}
	public Map<id,Boolean> m = new Map<id,boolean>(); 
	list<sObject> sortedList;
	public String myOrder{get;set;}                 // Ascending or Descending order of sorting
	public String sortField{get;set;}               // Field by which sorting should be done
	public boolean selectAll{get;set;}
	public list<String> alphabet{get;set;}
	public list<sObject> cont;
	public list<wrapper> allContactList = new list<wrapper>();
	public void fieldvalues(){
		query = fieldNames[0] + ' , ';
		for(Integer i=1;i<fieldNames.size();i++){
			query = query + fieldNames[i] + ' , ';
		}
		query='SELECT ' + query + ' FROM ' + 'objName';
	}
	public Integer RecordsPerPageslist{ 
        get;
        set{                                                          //To select number of records per page
            if(value!=null){
                this.RecordsPerPagesList=value;
                System.debug('RecordsPerPageList called');
            }
        }       
    }  
    public ApexPages.StandardSetController stdSetController{            //Instantiating a standard set controller
          get{
              if(stdSetController==null){
                    con = Database.query(query);
                    System.debug('con in ssc is : ' + con);
                   stdSetController = new ApexPages.StandardSetController(con);
              }
                stdSetController.setPageSize(RecordsPerPageslist);        //Limiting Number of records to be displayed per page 
                  System.debug('stdSetController called ');
              return stdSetController;   
          }
          set;
      }
    public list<wrapper> getWrapperContacts(){      //List of wrapper class to display in table
       for(sObject c:(list<sObject>)stdSetController.getRecords()){
       		allContactList.add(new wrapper(c));
       }
        return allContactList;
    }

    public class wrapper{
	  public boolean isSelected{get;set;}  
	  public sObject con{get;set;}  
	  public   wrapper(sObject con){
	          System.debug('constructor of wrapper class called ');
	          isSelected = false;
	          this.con = con;
	          }
	          
	      }
}
 
<apex:component controller="PaginationForComponent" >
    <apex:attribute name="objectName" description="The object's name" type="String" required="true" assignTo="{!objName}"/>
    <apex:attribute name="fieldName" description="Fields to be displayed" type="String[]" required="true" assignTo="{!fieldNames}"/>
    <apex:pageBlock >
        <apex:repeat value="{!getWrapperContacts}" var="repeat">
            <apex:outputText value="{!repeat}">
            
            </apex:outputText>
            
        </apex:repeat>
    
    </apex:pageBlock>
</apex:component>

 
Followed through the steps and I am receiving the error


There was an unhandled exception. Please reference ID: AKWLPXWN. Error: Faraday::ClientError. Message: INVALID_FIELD: SELECT Id FROM Contact where name='Edna Frank' ^ ERROR at Row:1:Column:30 field 'name' can not be filtered in a query call

Any suggestions?
Hi Guys,
i am creating Batch apex class to insert/update/delete records in my custom object emploee_profile from Profiles. I am able to insert but delete/update not working.

please see my code and guide me where i am wrong..actually i am beginner in salesforce:


global class ProfilesSync implements database.batchable<sObject>,Database.Stateful{
    
    global map<ID,Profile> ProfileRegMap=new map<ID,Profile>();
    global Database.QueryLocator start(Database.BatchableContext BC){
        System.debug('in start');
        try{
            return database.getQueryLocator([select ID,Name from Profile order by ID]);
        }
        catch(Exception e){
            System.debug('Error=='+e.getStackTraceString());
        }
        return null;
    }
    global void execute(Database.BatchableContext BC, List<Profile> ProfilesList)
    {
        System.debug('ProfileList=='+ProfilesList.size());
        if(ProfilesList!=NULL)
        {
            for(Profile rl:ProfilesList){
                ProfileRegMap.put(rl.ID,rl);
            }
        }
    }
    global void finish(Database.batchableContext BC){
        System.debug('UserProfileList=='+ProfileRegMap);
        List<Employee_Profile__c> Employee_Profile_list1 = new List<Employee_Profile__c>([select Profile_ID__c,Profile_Name__c from Employee_Profile__c order by Profile_ID__c]);
        List<Employee_Profile__c> Employee_Profile_list_Insert = new List<Employee_Profile__c>();
        List<Employee_Profile__c> Employee_Profile_list_update = new List<Employee_Profile__c>();
        List<Employee_Profile__c> Employee_Profile_list_delete = new List<Employee_Profile__c>();
        
        map<ID,Employee_Profile__c> custRoleMap=new map<ID,Employee_Profile__c>();
        for(Employee_Profile__c us:Employee_Profile_list1){
            custRoleMap.put(us.Profile_ID__c,us);
        }
 
            for(Profile urs:ProfileRegMap.values()){
                if(!custRoleMap.containsKey(urs.id)){
                  system.debug('New records');
                        Employee_Profile__c urs2 = new Employee_Profile__c();
                        urs2.Profile_ID__c=urs.id;
                        urs2.name=urs.id;
                        urs2.Profile_Name__c=urs.name;
                       Employee_Profile_list_Insert.add(urs2); 
              
                }
                
            }
            system.debug('size of cust list'+Employee_Profile_list_Insert.size());
            insert Employee_Profile_list_Insert;
           update Employee_Profile_list_update;
           delete Employee_Profile_list_delete;
    }
}
New to Apex...

Whenever a Task is created, I'd like to relate the Task's WhatID to the related Contact's (whoid) lookup field (custom field) TriggerTest__c. 

I have been receivin this error message : Error: Compile Error: Cannot save a trigger during a parse and save class call at line -1 column -1
 
trigger TaskRelatedToContact on Task (after insert,after update) {


Set<Id> ContactIds = new Set<Id>(); for(Task t : trigger.new)
{String wId = t.WhoId; 
if(wId!=null && wId.startsWith('003') && 
   !ContactIds.contains(t.WhoId)) 
    
    { ContactIds.add(t.WhoId); } }


List<Contact> 
taskContacts = [Select Id, TriggerTest__c 
from Contact where Id in :ContactIds]; 
Map<Id, Contact> ContactMap = new Map<Id, Contact>(); 
for(CONTACT c : taskContacts)
{ ContactMap.put(c.Id,c); } 


for(Task t : trigger.new){ String wId = t.WhoId; 
if(wId!=null && wId.startswith('003')){CONTACT thisContact = ContactMap.get(t.WhoId); 
if(thisContact!=null){t.WhatId = thiscontact.TriggerTest__c;} 
} 
} 
}

 
  • April 24, 2018
  • Like
  • 0
I have created a visualforce component and would like to use $Action.object name.action name($Action.Contact.Del) within it but i am getting the above error. Following is my controller and component code:
Component code
<apex:component controller ="PaginationForComponent">
    <apex:attribute name= "objectName" description = "The object's name" type = "String" required = "true" assignTo="{!objName}"/>
    <apex:attribute name= "fieldName" description = "Fields to be displayed" type = "String" required ="true" assignTo="{!fieldNames}"/>
<apex:outputLink value="{!URLFOR($Action."{!objName}".Edit,contacts.con.id)}"> 
                        Edit |
                    </apex:outputlink>
                    <apex:outputLink value="{!URLFOR($Action."{!objName}".Delete,contacts.con.id)}"> 
                        Del |
                    </apex:outputlink>

Controller code:
public class PaginationForComponent {
public String objName{get;set;}
	public String fieldNames{get;set;}
}

Ps: Only relevant code is provided here​
Hi All,

I need soql query to retrive number of Cases created by Contact in an accounts.
Hello,

I am looking to create a custom field that will update after event insert to count the number of RelationId's on each event. Help please!
Hi,

We are making a callout to external endpoint from Salesforce to get the attachments. when attachment size is more than 6 MB its throwing me Heap size limit error and we are running this callout from future method, where we are having this limit as 12 MB.

Please advise .... on any workarounds to overcome this ..
 
@future(callout=true)
    public static void SendAttachmentsToCase(Map<string,string> Initialres,ID CaseID,ID UserID,string UserName,string Password,string ticketNumber,string jobtime)
    {

                // Performs another callout to get appropriate attachment 
               List<attachment> FinalAttachmentList = new List<attachment>();
               for(string sg : Initialres.Keyset()) // Map of attachment Names and endpoint
               {
                Http h2 = new Http();
                HttpRequest req2 = new HttpRequest();
                Blob headerValue = Blob.valueOf(UserName+':'+Password);
                String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
                req2.setHeader('Authorization', authorizationHeader);
                req2.setHeader('Content-Type','application/json');
                req2.setEndpoint(Initialres.get(sg));
                req2.setMethod('GET');
                req2.setTimeout(60000);
                try
                {
                system.debug('heap size before req'+' '+ Limits.getHeapSize());
                HttpResponse res2 = h2.send(req2);
                system.debug('resposne'+ ' '+res2.getBody());
                                system.debug('heap size after req'+' '+ Limits.getHeapSize());

                blob image = res2.getBodyAsBlob(); 
                Attachment a = new Attachment (ParentId = CaseID,
                                           Body = image,
                                           OwnerId = UserID,
                                           CreatedById = UserID,
                                           Name = sg);
               FinalAttachmentList.add(a);
                }catch (Exception e)
                {
                    system.debug('exception message at 2nd callout level'+ ' '+ e.getMessage());
                 }
              }

              insert FinalAttachmentList;
    }

 
  • April 17, 2018
  • Like
  • 0