• developer_force
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 9
    Replies

HI ,

 

Hepl needed in writing the code the code in such a way that it handles bulk records

Here is the code and iam not sure if it handles the bulk records

 

public with sharing class SalesTargetHandler {

Map<String, Sales_Target__c> offCode = new Map<String, Sales_Target__c>(); Sales Target id
Set<ID> salesTargetId = new Set<ID>();

public SalesTargetHandler(){
}

public void OnBeforeInsert(Sales_Target__c[] newRecords){
for(Sales_Target__c newSalesTarget : newRecords){
offCode.put(newSalesTarget.Officer_Code__c, newSalesTarget);



for(Sales_Target__c salesTarget :[Select Id ,Officer_Code__c, Target_Period_Start__c ,Target_Period_End__c from Sales_Target__c where Officer_Code__c IN :offCode.keySet()])
{

Sales_Target__c st1 = offCode.get(newSalesTarget.Officer_Code__c);
if(salesTarget.Officer_Code__c == st1.Officer_Code__c &&
((salesTarget.Target_Period_Start__c <= newSalesTarget.Target_Period_Start__c &&
salesTarget.Target_Period_End__c >= newSalesTarget.Target_Period_Start__c)
|| (salesTarget.Target_Period_Start__c<= newSalesTarget.Target_Period_End__c &&
salesTarget.Target_Period_End__c>= newSalesTarget.Target_Period_End__c)
)){

String errorMsg = System.Label.Sales_Target_Error_Message;
newSalesTarget.addError(errorMsg);
}
}
}
}

 

Thanks

Hi ,

 

Help needed with the below code.

 

The custom field 'Actual_Number_Of_Sales__c' on Sales_Target__c should get updated with the count number based on the certain condition as mentioned below in the code.

 

trigger afterTrigger on Sales_Target__c (after insert){

 

Sales_Target__c[] newRecords = trigger.new;

set<id> salesTargetId = new set<id>;

 

for(Sales_Target__c salesTarget : newRecords){

salesTargetId.add(salesTarget.id);

Integer sales = [select count() from Sales_Opportunity__c where Count_Against_Targets__c = true AND
Sales_Target__c IN : salesTargetId AND status__c = 'Closed Won'];


salesTarget.Actual_Number_of_Sales__c = sales;


Integer calls = [select count() from Task where Count_Against_Targets__c = true AND Sales_Target_ID__c IN : salesTargetId];
salesTarget.Actual_Number_of_Calls__c = calls;
}

 

Norte: There is an anothet object called Sales_Opportunity__c which has a lookup relationship to the Sales_Target__c object.

 

When iam trying to create and save a record on Sales_target__c ,its giving me the below erroe on the lines highlited in red.

 

Apex trigger SalesTargetTrigger caused an unexpected exception, contact your administrator: SalesTargetTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only: 

 

Any help is appreciated..

 

Thanks

Hi,

 

Help needed in updating a custom field on Task

 

I have a custom field calld Sales_Targer_Id__c on task object and this field need to be get updated by the Id of Sales_Target__c object

 

And the condition for that is if the officer_code__c of Task is equal to Officer_code__c of sales_Target__c object then update the Sales_Targer_Id__c custom field with the id of the Sales_Target__c custom object.

 

Thanks

Hi,

 

Need help with the error below

 

Here is the trigger handler class where iam implementing the before insert trigger

 

public void OnBeforeInsert(Sales_Target__c[] newRecords){


newRecords = trigger.new;
for(Sales_Target__c newSalesTarget : newRecords)
{
if ((newSalesTarget.Officer_Code__c != null) &&
(newSalesTarget.Officer_Code__c= System.Trigger.oldMap.get(newSalesTarget.Id).Officer_Code__c))

}

 

and the error i got is "Field expression not allowed for generic SObject '' at the line highlighted in red. Not sure what that mean.

 

Thanks

HI,

 

Help needed in writing the test class for below class

 

      

public with sharing class ReportParam {

    Public PageReference redirectReport()
    {
    
        Id testId = ApexPages.currentPage().getParameters().get('id'); 
        String cn = ApexPages.currentPage().getParameters().get('cn');
        ReportParamBuilder_Config__c  r = ReportParamBuilder_Config__c.getValues(cn);
        string qry = 'select '+r.QueryObjectField__c+' from '+r.QueryObjectName__c+' where '+r.QueryObjectPrimaryRefField__c+'=\''+testId+'\'';
        List<SObject> resList = database.query(qry);
    System.debug('----------ResultList:'+resList);
        String stringUrl='';
        if(r.QueryObjectName__c == 'Relationship_Group_Member__c'){
            List<Relationship_Group_Member__c> rgmList = (List<Relationship_Group_Member__c>)resList;
            for(Relationship_Group_Member__c obj : rgmList)
            stringUrl = stringUrl +',' + obj.Group_Id__r.GCIF__c;

}


PageReference p = new PageReference('/'+r.ReportId__c+'?pv0='+stringUrl);
        Return p;
    }

}

 

Thanks

       

public with sharing class ReportParamBuilderController {

    Public PageReference redirectReport()
{

Id testId = ApexPages.currentPage().getParameters().get('id'); 
String cn = ApexPages.currentPage().getParameters().get('cn');

List<ReportParamBuilder_Config__c > listTest = [Select ReportId__c ,QueryObjectField__c , QueryObjectPrimaryRefField__c from
ReportParamBuilder_Config__c where QueryObjectPrimaryRefField__c = :testId];

String stringUrl;
For(ReportParamBuilder_Config__c obj : listTest)
{
   stringUrl = stringUrl + ',' + obj.QueryObjectField__c;
}
PageReference p = new PageReference('/00OM0000000SNcO?pv0='+ stringUrl);
Return p;
}

 

can i get the visualforce for the above code . But the vf page should contain the the output link as mentioned in the pagereference and should redirect to that age

 

Thanks

PageReference p = new PageReference('/00OM0000000SNVS+?pv0=’+ stringUrl);

 

the error says "line breaks not allowed in string literals at line 17 column -1"

 

Can anyone pls help to fix thsi error

 

Thanks

 

HI,

 

need help in this

 

List<QueryObjectPrimaryRefField__c > listTest = new List<QueryObjectPrimaryRefField__c>(SELECT QueryObjectField__c fromQueryObjectName__c where QueryObjectPrimaryRefField__c = :ApexPages.currentPage().getParameters().get('id'));


the error says "expecting a right parentheses, found 'SELECT' at line 34 column 88"

HI,

 

I need help in using the custom setting object in vf page and controller to generate reports.

 

I created a custom setting object called ReportConfig with some column names like Name , ReportID , QueryObjectName . The name has the Report name and ReportId has the id of the base report which was created and saved leaving filters as blank and QueryObjectName has the Name of the object which should be queried.

 

Like described above i have created four records for custom setting object.

Now a hyperlink formula field should be created on the object on which i will be quereying. So , when the user go to the particular record and click on the hyperlink of that formula field which should direct to the visualforce page called ReportParamBuilder then VF page loads the respective ReportConfig record with the Name


A Visualforce page should be created and it should accept the following parameters

config  -config name

id  -SFDC id of the record that the integration is being launched from

 

Using the parameters from the ReportConfig object and from the URL, the VF page constructs the  query and then the results are parsed and every returned record’s data will be added to a comma separated string an then 

 

 

1)T The Visualforce page will construct a report url like the following:

      /00OM0000000SNVS? pv0=<generated comma separated string>

The Visualforce page would redirect the user to this new page. which i s a reports page.

This is my requirement. any sample code is really appreciated.

 

Thanks

Hi,

 

Help needed in retreiving all the users in salesforce using Apex code.

 

Thanks

can anyone please help me in writing a trigger which should populate some 'test' field to the Account name.

 

If its business account 'test' field should be populated to just 'Name'

If its Person Account  , 'test' field should be populated to 'FirstName+MiddleName+LastName'

 

Thanks

 

 

HI,

 

How can we sync the picklist values with that of the values in other table.

 

Ex: I have a country field in the Account object which is a picklist. It contains all the country names

Now i have another object called country which has fields called country code and country name. The name field contains all the country names. 

 

Now how do i sync the values of the country field in Account object with the values of the country name field of the country object.

 

Thanks

 

Hi,

 

Help needed in writing a trigger for the following logic.Org is using Person Accounts

 

if RecordType= personaccount some 'test' field should be populated to 'firstname+lastname+middlename '

 

 

Thanks

Hi,

 

Help needed in writing a trigger for the following logic.Org is using Person Accounts

 

if RecordType= personaccount some 'test' field should be populated to 'firstname+lastname+middlename '

 

Thanks

 

Help needed in creating a Formula field on person Accounts.

 

I need a person Account field to create a formula field , but I could not see the person Account fields when iam trying to insert the fields in to the formula editor. I could only see the Account fields

 

Thanks

Hi ,

 

Help needed with the below code.

 

The custom field 'Actual_Number_Of_Sales__c' on Sales_Target__c should get updated with the count number based on the certain condition as mentioned below in the code.

 

trigger afterTrigger on Sales_Target__c (after insert){

 

Sales_Target__c[] newRecords = trigger.new;

set<id> salesTargetId = new set<id>;

 

for(Sales_Target__c salesTarget : newRecords){

salesTargetId.add(salesTarget.id);

Integer sales = [select count() from Sales_Opportunity__c where Count_Against_Targets__c = true AND
Sales_Target__c IN : salesTargetId AND status__c = 'Closed Won'];


salesTarget.Actual_Number_of_Sales__c = sales;


Integer calls = [select count() from Task where Count_Against_Targets__c = true AND Sales_Target_ID__c IN : salesTargetId];
salesTarget.Actual_Number_of_Calls__c = calls;
}

 

Norte: There is an anothet object called Sales_Opportunity__c which has a lookup relationship to the Sales_Target__c object.

 

When iam trying to create and save a record on Sales_target__c ,its giving me the below erroe on the lines highlited in red.

 

Apex trigger SalesTargetTrigger caused an unexpected exception, contact your administrator: SalesTargetTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only: 

 

Any help is appreciated..

 

Thanks

Hi,

 

Help needed in updating a custom field on Task

 

I have a custom field calld Sales_Targer_Id__c on task object and this field need to be get updated by the Id of Sales_Target__c object

 

And the condition for that is if the officer_code__c of Task is equal to Officer_code__c of sales_Target__c object then update the Sales_Targer_Id__c custom field with the id of the Sales_Target__c custom object.

 

Thanks

Hi,

 

Need help with the error below

 

Here is the trigger handler class where iam implementing the before insert trigger

 

public void OnBeforeInsert(Sales_Target__c[] newRecords){


newRecords = trigger.new;
for(Sales_Target__c newSalesTarget : newRecords)
{
if ((newSalesTarget.Officer_Code__c != null) &&
(newSalesTarget.Officer_Code__c= System.Trigger.oldMap.get(newSalesTarget.Id).Officer_Code__c))

}

 

and the error i got is "Field expression not allowed for generic SObject '' at the line highlighted in red. Not sure what that mean.

 

Thanks

 

HI,

 

need help in this

 

List<QueryObjectPrimaryRefField__c > listTest = new List<QueryObjectPrimaryRefField__c>(SELECT QueryObjectField__c fromQueryObjectName__c where QueryObjectPrimaryRefField__c = :ApexPages.currentPage().getParameters().get('id'));


the error says "expecting a right parentheses, found 'SELECT' at line 34 column 88"

can anyone please help me in writing a trigger which should populate some 'test' field to the Account name.

 

If its business account 'test' field should be populated to just 'Name'

If its Person Account  , 'test' field should be populated to 'FirstName+MiddleName+LastName'

 

Thanks

 

 

 

Help needed in creating a Formula field on person Accounts.

 

I need a person Account field to create a formula field , but I could not see the person Account fields when iam trying to insert the fields in to the formula editor. I could only see the Account fields

 

Thanks