• F Smoak
  • NEWBIE
  • 34 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 43
    Replies
Hi

I am writing a trigger wherein as first step I need to create a map containing its parent id, Set of text field values which are possibly duplicates for that object records.
Code:
trigger CMS_Insert_MCCP on CMS_Rule_Line_Item__c (after Insert) {
        Map<id,Set<String>> poateamMap =  new Map<id,Set<String>>(); //poaid vs set of team
    List<CMS_Rule_Line_Item__c> cbList= trigger.new;
        for(CMS_Rule_Line_Item__c crRecord: cbList){
        if(!poateamMap.containsKey(crRecord.Rule_Name__c)){
            poateamMap.put(crRecord.Rule_Name__c,new Set<String>{crRecord.CMS_Team__c});
            }
            else{
                Set<String> str = new Set<String>();
                str =  poateamMap.get(crRecord.Rule_Name__c);
                if(str != crRecord.CMS_Team__c) {
                   poateamMap.put(crRecord.Rule_Name__c,crRecord.CMS_Team__c);
            }
            } }

Here Iwould like to ensure that Rule_Name__c (stores parent id) has corresponding set of records having only one distinct team value for it in that set.
I am missing something but cannot figure out. Please help!
I have written a beow code where I have a text field on my object which populates duplicate values of territory name. I need to retrieve a set of this field value (in form of string as the field data type is text) but getting following error.- DML requires SObject or SObject list type: Set<String> in below bold line
Please help!
code:
trigger CMS_Insert_MCCP on CMS_Rule_Line_Item__c (after Insert) {
    List<Territory> territoryList = new List<Territory>();
    List<MC_Cycle_Plan_vod__c> mccp =  new List<MC_Cycle_Plan_vod__c>();
    Set<String> teamList = new Set<String>();
        for(CMS_Rule_Line_Item__c crRecord: Trigger.new){
        teamList.add(crRecord.CMS_Team__c);
    }
       insert teamList;
}
 
I have russian values for picklist field values in my org and I would like to query these out and show it to end users as records in custom object. But I dont see anyway to query in translation workbench. ANy help would be appreciated!
I have to delete alerts whne expiration datetime has reached today's datetime
My expiration datetime is showing as 2019-10-05T00:00:00.000Z
I want to delete this record on 5th Oct but I am getting unknown error parsing query when I execute in query editor:
Select Id from Alert_vod__c where Expiration_Date_vod__c <= system.now()

Please help.

 
share records with the end user when created by batch class
I have a requirement:

For an account in user's territory, we have calls created. Now based on this I need to create alerts where user can view alerts showing his account got calls on which date by which user in last 7 days. For this I need to create a batch but since all alerts are created by admin end user do not have access to alerts. How to fix this?
Please find my code below:

global class BatchCreateAlertforCalls implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) {  
    
    String query = 'SELECT Id,Call_Date_vod__c,Account_vod__c,createdby.name FROM Call2_vod__c where Status_vod__c = \'Submitted_vod\' AND Call_Date_vod__c = N_DAYS_AGO:7 AND OwnerId!=\'005U0000001vQ0a\'';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<sObject>scope) {
        List<Call2_vod__c> callList = (List<Call2_vod__c>) scope;
        system.debug('call list>>>>'+calllist);
        List<Alert_vod__c> alertsubmittedcalllist = new List<Alert_vod__c>();
        for(Call2_vod__c call: callList){
         Alert_vod__c alert = new Alert_vod__c();
            alert.Activation_Date_vod__c = system.now();
            alert.Alert_Text_vod__c = call.Account_vod__c+' seen by '+call.createdby.name;
            alert.Link_Reference_vod__c =call.Id;
            alert.Expiration_Date_vod__c = system.now()+1;
            alertsubmittedcalllist.add(alert);
        }
        if(alertsubmittedcalllist.size() >0)
        {
            insert alertsubmittedcalllist;
            system.debug('alert list>>>>'+alertsubmittedcalllist);
        }
}
     global void finish(Database.BatchableContext BC) {
        // execute any post-processing operations
  }
}
I am trying to create a new territory and assign it to my existing 3 child territories as parent. WHile deploying to target org, I am getting above error in validating change sets for 2 of my 3 child territories.
Kindly let me know how to fix this.
I am trying to retrieve user IDs which do not belong to those territories whose names starts with IT_CH, but getting error "Unknown error parsing query" in dev console query editor.
Please note I need to use this as a single query and not via executing a class having for loops traversing from Territory to UserTerritory to User:

Select Id from User where Id in (Select UserID from UserTerritory where NOT TerritoryID.name LIKE 'IT_CH%'))

Please help.
I am new to salesforce, I have some confussion with Apex managed sharing, where we can use exactly in real time?

Please clear my confussion..

Thanks in advance

I am stuck on writing a query to facilitate Congra Composer.  For reasons beyond this request, I need to 'dedupe' a query of data as well as put it into a set order.  I can easily do one or the other but not both.  If I do an ORDER BY I get all results using the following SOQL:

SELECT Group__c, Order__c FROM OpportunityLineItem WHERE Opportunity.Id = 'xxxxxxxxxxxx' Order by Order__c

Which returns:

1   Eggs
1   Eggs
2   Tomatoes
2   Tomatoes
3   Bananas
3   Bananas

However that does not allow me to 'dedupe' as i would if I used the following SOQL:

SELECT Group__c FROM OpportunityLineItem WHERE Opportunity.Id = 'xxxxxxxxxxx' GROUP BY Group__c

Which returns:

Eggs
Tomatoes
Bananas

So... When I put it all together in hopes of getting (1 Eggs, 2 Tomatoes, 3 Bananas) with the following SOQL:

SELECT MAX(Order__c), Group__c FROM OpportunityLineItem WHERE Opportunity.Id = '0064000000Rw0ea' GROUP BY Group__c ORDER BY Order__c

I get various "MALFORMED_QUERY: Ordered field must be grouped or aggregated: Order__c" Errors

Any ideas on how to achieve an ordered and distinct (deduped) query?

 

So I'm trying to do an aggregate query in Batch Apex and of course I'm running into the error "Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch" which is useless since of course the whole idea of an aggregation is get everything you need without a LIMIT.

 

I tried using the scope parameter on database.executeBatch because the documentation implies that it changes the batch size so I tried 3,000 since that is the quantity of records I have, but I still got the querymore error.

 

It looks like aggregate queries really cannot be used in Batch Apex.  Oh sure, for 20 records maybe, but not for 200+, i.e. the real world.  Can anyone confirm that?

 

Also, what does the scope parameter on database.executeBatch really do?  Does it only throttle down the batch size, or can you use it to throttle up the size?  If so, then why doesn't it work for aggregate queries?

 

Thanks

David

 

 

Hi,
in the Winter'09 release notes it says "Custom labels are custom text values, up to 1,000 characters in length, that can be accessed from Apex classes or Visualforce pages".
I could easily find how to access these labels from a visualforce page, but nowhere I can find how to access them from an apex class.
I need this because I have a class that dynamically generates labels for a certain table in a vf page. But I want to use Custom Labels (and the translation workbench) to get these translated in various languages.
Is there an object, something like Label with a static function like 'getLabel(String)'? Or is this not released in Winter '09?