• Montu rai
  • NEWBIE
  • -1 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 9
    Replies
I am writing Batch Apex Query String where the soql limit I want to avoid.How can we avoid the limit in below batch code ?

     DateTime currentTime = System.now();
      DateTime ddd = currentTime.addHours(-2);
      list<Total__c> campaignInfluenceList = new List<Total__c>();
      campaignInfluenceList = [select Id,CampaignId__c,OpportunityId__c,CampaignId__r.unique__c from Total__c where lastmodifieddate>=:ddd];
            Set<Id> oppIds = new Set<Id>();
//how to avoid soql limit in below for loop.
            for(Total__c d:campaignInfluenceList){
                oppIds.add(d.OpportunityId__c);
             }
             
                  String str = 'opportunityCreatedFromLead';
     string query='Select Id,Name,unique__c,Type,Lead_ID__c,createdby.profile.Name,(select Id,CampaignId__c,OpportunityId__c,CampaignId__r.Source__c from Total__r ) from Opportunity where id=: oppIds ';
     
     return Database.getQueryLocator(query); 

Thanks,

Our schema when we migrated from the previous CRM to Salesforce was an absolute nightmare.  Once we moved to SF, I was granted the role as our SF admin.  After building our integration to our website, I thought I had grown to be very familiar with most of our data.  There is a specific permission that I need to grant on the website based on a pretty awful series of rollups that need to happen, but I'm struggling to get everything to work correctly.  I'll try to properly map out the chain of events that need to be followed.  I am using DLRS to do what I can.

The primary objects that need to be focused on are as follows (mostly custom objects): Account, License Servers, License Sites, License Products, License Content

License Product contains the determining value
License Content has a lookup to License Product and License Server
Account has a lookup to License Server but none of the others.
License Sites has a lookup to up to 2 different accounts ( main and secondary locations), but none of the others.

1) If License Content is associated with a License Product that contains a specific value, and the License Content expiration date is not past, then the value is equal to the amount of license seats exist in License Content.
2) If the License Content has this value > 0, then License Server sees this value as available seats for this desired License.
3) If License Server shows a positive number of active seats, then the Account will know that it has X amount of seats.

This is where it gets weird, because Account needs to reflect the total of available seats for both the License Site where it is the main location AND ALL of the License Sites where it is a secondary location.

So to add to the previous steps, Account needs to show a value equal to the number of seats from the site where it is the main location, PLUS all of the sites where it is the secondary location. 

Currently, what I have in place is as follows:

1) License_Content__c has a formula field to show active seats of the designated license if it has not expired.  (WORKS)
2) License_Server__c has a Number field where DLRS looks uses a lookup relationship From License_Server__c to License_Content__c where the lookup ID = the License_Server__c record. (WORKS)
3) Account needs to reflect the number of seats where it is a main location.  I have a DLRS rollup where the Parent is Account, the Child is License_Server__c and the relationship field is the ID of the Account.  The field to aggregate is the correctly populated field from step 2 (DOES NOT WORK - BLANK)
4) License_Sites__c needs to do its own separate rollup where each License_Site__c record reflects the number of active seats in its secondary location, so Accounts step 3 needs to function for this to work
5) Account now needs a rollup that contains the total number of license seats where it is a secondary location in License_Sites__c. 

This structure is horrible, but it has been in place for years and years, and I don't think there is any way we can consolidate and normalize.  I've been working on this problem for far too long, and I'm still running into issues with step 3, even though the correct values are in place and it just seems like the DLRS summary is not filling any values in.  This whole thing is super overwhelming because of how massively confusing it is, so there might be a really easy way to take care of this that I'm not seeing. 

Is there a simpler way to handle this?  Or do I need to change the way I am using these DLRS rollups?  Please let me know if any clarity is needed on the process that should be followed.


 
Hi all,

We need to implement the following pattern at my org:
  • callout to external data source
  • if that callout takes too long (according to some configurable threshold), log an error (ie do some DML)
  • if that callout timed out on the remote server, try it again
Recognizing the potential for the dreaded "You have uncommitted work pending. Please commit or rollback before calling out." error, I put the error logging code in a future method, thus isolating the DML from the callouts. However, the error is still being thrown. I reduced the issue down to this pattern:
public static void foo() {
    Http http = new Http();
    HttpRequest req = new Httprequest();
    req.setEndpoint('https://test.salesforce.com'); //whatever endpoint
    req.setMethod('GET');
    http.send(req); //works fine
    bar();
    http.send(req); //throws calloutexception
}

@future public static void bar() {

}
Am I correct to assume that calling a future method counts as a DML operation? Is there any documentation I'm missing somewhere?

 
I am looking for help to run a Join Query to find all out Accounts in our Database without Contacts AND Opportuntiy.  I can run the query indepetly, but I would like to join the queries. 

The Query I am runing to find Accounts without Contacts: Select Id, Name From Account Where Id NOT IN (SELECT AccountId FROM Contacts)
Query to find Accounts without Opportunties: Select Id, Name From Account Where Id NOT IN (SELECT AccountId FROM Opportunity)
In Objective C, I follow the steps as outlined here and it works fine: https://developer.salesforce.com/docs/atlas.en-us.noversion.mobile_sdk.meta/mobile_sdk/ios_rest_apis_using_methods.htm?search_text=forceios

But when following the same steps translating the code into Swift, I run into an issue with the SFRestRequest initializer, whose signature is below:
 
Public convenience init(method: SFRestMethod, path: String, queryParams: [String : String]?)

As you can see, queryParams takes a Swift Dictionary with a key and value of the String type.  But when you follow the example, it seems you end up with a Dictionary with a key of the String type and value of the Dictionary type; and thus we have a type mismatch.

This doesn't seem to be a problem in Objective C, because upon inspection of the method signature in SFRestRequest.m, queryParams appears to be able to take a generic NSDictionary: 
 
+ (instancetype)requestWithMethod:(SFRestMethod)method path:(NSString *)path queryParams:(NSDictionary *)queryParams

For reference here is the Swift code I'm trying out:
 
//build the queryParams dictionary from a JSON String
let body: String = "{ \"body\" :{\"messageSegments\" :[{ \"type\" : \"Text\",\"text\" : \"My Comment\"}]}}"
        let queryParams = SFJsonUtils.objectFromJSONString(body) as! [String:AnyObject] 
//construct and send the request
        let request = SFRestRequest(method: SFRestMethod.POST, path: "/services/data/v36.0/connect/communities/my_community_ID/chatter/feed-elements/my_element_ID/capabilities/comments/items", queryParams: queryParams as? [String:String])
        SFRestAPI.sharedInstance().send(request, delegate: self)

But unwrapping queryParams fails and resolves to nil.  Trying to forcefully cast queryParams to [String:String] does not work either, and just causes a crash.

How might I get around this?
 
I could use some assistance. We have a SalesForce customer portal and in a number of my orgs, the reset password email is not being sent to the users, either via the Forgot Password link or the Admin Reset Password button in User tab. The Forgot Username email works as expected though. The Forgot Password flow works fine in some of my other orgs and as far as I can tell, all settings are identical.

I have verified in Setup -> Email Administration -> Deliverability that Access Level is set to 'All email'.
In Setup -> Email Administration -> Test Deliverability, I have verified that I receive all 48 test emails.
In Setup -> Communication Templates -> Email Templates -> Forgot Password, I have tried the 'Send Test and Verify Merge Fields' and received the test email.
The Email Log File shows that all forgot password emails are being delivered and received (although they never actually make it to the inbox).

I am not sure if there is an issue with Site.forgotPassword() or if somehow the Forgot Password email template is not mapped properly to the Forgot Password workflow. I do know that the orgs that are having issues have the same managed package as the orgs that are working.  
Not sure where to go from here?

Any help is appreciated.

Hi,

 

Is there a way we can add a time to now()?

 

My present time is 4/26/2011 6:43 PM.

I have a text formula as "TEXT(NOW())", but I am getting a result of "2011-04-26 10:43:51Z" which is 8 hours late hence i would like to add 8hours to my formula.

 

Also, is it possible to format the result exactly the same as "4/26/2011 6:43 PM"?

 

Thanks a lot.

 

Del