• surojit Mondal
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
How to solve this type of error "java.lang.OutOfMemoryError: Java heap space" ?
I have googled the issue and got that the heap memory might be cause of this error.But larger file has been processed previously and does not occour any error. I have also attached the screenshoot of generated log.

Larger file size does not generate error message
I am returning a list of object fields from my apex controller to form a table. Now suppose I  the value of only one of the fields from that list to use somewhere else. How can i do that?
Below is my apex method where I'm updating Account_Transfer__c Records
private static void linkPoliciesAndHandleApprovalFlds(
    List<string> selectedPoliciesSet,
    Account_Transfer__c accTrans,
    Office__c toOffice,
    Office__c fromOffice
) {
    Map<Id, Account_Transfer__c> AcctransMap = new Map<Id, Account_Transfer__c>(); 
    String districtAccountCode = '';
    List<Policy__c> selectedPolicies = new List<Policy__c>(
        [
            SELECT
                Id,
                District_Acct_code__c,
                Account_Transfer__c,
                Plan_Code__c
            FROM Policy__c
            WHERE ID IN :selectedPoliciesSet
        ]
    );
    List<Account_Transfer_Policy__c> accTransferPolicy = new List<Account_Transfer_Policy__c>();
    for (Policy__c pol : selectedPolicies) {
        Account_Transfer_Policy__c atp = new Account_Transfer_Policy__c();
        atp.Account_Transfer__c = accTrans.Id;
        atp.Policy__c = pol.Id;
        accTransferPolicy.add(atp);
      
        
    }
    

    

    accTrans.District_To__c = districtAccountCode;
    AcctransMap.put(accTrans.id, accTrans);
    
    update AcctransMap.values();
    
    insert accTransferPolicy;
    
    Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
    req.setObjectId(accTrans.Id);
    req.setSubmitterId(UserInfo.getUserId());
    Approval.process(req);
    
}
Now this code isn't throwing me any errors but in the record page, I'm getting the error as
 
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
I am using Map here to get the ids of Account Transfer records and using them to update by calling map.values(). I'm wondering why it is mentioning that Ids are not specified in the update call.

Can anyone please suggest if there is anything missing
Want to write a trigger on user, so for any user has einstein user package license, if any user of profile other than system admin and standard security is trying to update the user's profile should throw an error.

Also if the profile is changed to the new profile with prefix SM then also should throw the error.
public class errorMsgOnProfileUpdate {
    
    public static void errorMsgOnProfileChange (List<user> userList, Map<id,user> oldMap) {
        profile pf;
        userList = [Select Id, Profile.Name, ProfileId from User where  isActive = TRUE and Profile.UserLicense.LicenseDefinitionKey = 'SFDC' and Id in (SELECT UserID FROM UserPackageLicense WHERE (PackageLicenseId= '050800000004xiQ'))];
        pf = [Select Id, Name from Profile where Name = 'System administrator' or Name = 'Standard Security'];
        if(userList.size() > 0){
            for(User u: userList){
                if(trigger.isUpdate && u.Profile.Name != pf.Name && oldMap.get(u.id).ProfileId != u.ProfileId){
                    u.addError('Only system Administrator and security has access to edit profiles');
                }
            }  
        } 
    }
    
}
Please correct me as I'm gettin the exception error while updating the profile as below:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UserTrigger caused an unexpected exception, contact your administrator: UserTrigger: execution of BeforeUpdate caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): ()

 
Hi 
Hope everyone is healthy and safe.
I have 2 checkboxes, Accept or Reject
1 comment box
If user selects Reject checkbox and its true then Comments need to be Required. 
I place this code in 
<apex:inputTextarea value="{!accWrap.comments}" id="cmmts" required="{!IF(!accWrap.rejected==true, true, false)}" />

but it makes it required for everything, even when user selects accept and for all records.
Please see my code below and assist. thank you
<apex:page controller="ZCQController" sidebar="false" docType="html-5.0" lightningStylesheets="true">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){                                     
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <script>
        function confirmDisbaled(ifchecked, id1 ,id2) {
            document.getElementById(id1).disabled = ifchecked;
            document.getElementById(id2).disabled = ifchecked;
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="All Pending Quotes" collapsible="false" columns="2">
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Quotes" >
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Quote_Status__c}" />
                    <apex:column value="{!accWrap.acc.Quote_Number__c}" />
                    <apex:column headerValue="Approve">
                        <apex:inputCheckbox value="{!accWrap.approved}" id="inputId2" onchange="return confirmDisbaled(this.checked, '{!$Component.inputId3}');"/>
                    </apex:column>                      
                    <apex:column headerValue="Reject">
                        <apex:inputCheckbox value="{!accWrap.rejected}" id="inputId3" onchange="return confirmDisbaled(this.checked, '{!$Component.inputId2}');"/>
                    </apex:column>
                    <apex:column headerValue="Comments">
                        <apex:inputTextarea value="{!accWrap.comments}" id="cmmts" required="{!IF(!accWrap.rejected==true, true, false)}" />
                    </apex:column>
                </apex:pageBlockTable>          
                <apex:pageBlockTable value="{!att}" var="a" id="table2" title="All Associated Attachments">
                    <apex:column headerValue="Download">
                        <apex:outputLink value="{!URLFOR($Action.Attachment.Download, a.Id)}" target="_blank">View</apex:outputLink>
                    </apex:column>
                    <apex:column value="{!a.Parent.Name}" headerValue="Quote Number"/>
                    <apex:column value="{!a.Name}" headerValue="File Name"/>
                    <apex:column value="{!a.LastModifiedDate}"/>  
                </apex:pageBlockTable>
            </apex:pageblockSection>
        <apex:pageblockSection >
            <apex:commandButton value="Save" action="{!save}" />
        </apex:pageblockSection>  
    </apex:pageBlock>
</apex:form>
</apex:page>

 
Developer console is Salesforce's way for us to check debug logs, track governor limit issues, run queries, and generally just debug all of our developer stuff.... and yet, it's TERRIBLE.

It freezes constantly, it often says it couldn't finish "long running operations", switching perspectives causes the whole browser to lock up, and then once the perspective finally changes it takes a huge amount of time to go from tab to tab (if you can go at all). Once it freezes/crashes, good luck getting it back up because it takes forever to load (if it even loads at all).

This thing is supposed to be our lifeline, our tool to help figure out what's wrong, and I can't even get it to work. Is there an alternative to this poorly implemented program? I can't stand this anymore, I've been trying to suffer through it for 3-4 years now and enough is enough. Why do more people not complain about this tool, and why has Salesforce not released something better by now?
Hi I have created below trigger to create the contact when a case is inserted via web-to-case.  There is no error, and I am not sure why the contact is not getting created.  I have only one custom field on contact to mark as auto created, rest all are standard fields. Can anybody help to figure out the issue.. 

trigger AutocreateContactfromCase on Case (before insert) {
    List<String> emailAddresses = new List<String>();
    for (Case caseObj:Trigger.new) {
        if (caseObj.ContactId==null && caseObj.SuppliedEmail!='')
        {
            emailAddresses.add(caseObj.SuppliedEmail);
             
        }
    }
    List<Contact> listContacts = [Select Id, Email From Contact Where Email in :emailAddresses];
    Set<String> takenEmails = new Set<String>();
    for (Contact c:listContacts) {
        takenEmails.add(c.Email);
    }
    Map<String,Contact> emailToContactMap = new Map<String,Contact>();
    List<Case> casesToUpdate = new List<Case>();
    for (Case caseObj:Trigger.new) {
        if (caseObj.ContactId==null &&
            caseObj.SuppliedName!=null &&
            caseObj.SuppliedName!='' &&
            caseObj.SuppliedEmail!=null &&
            caseObj.SuppliedEmail!='' &&             
            caseObj.SuppliedPhone!=null &&
            caseObj.SuppliedPhone!='' &&            
            !takenEmails.contains(caseObj.SuppliedEmail))
         {
            String[] nameParts = caseObj.SuppliedName.split(' ',2);
            if (nameParts.size() == 2)
            {
                Contact cont = new Contact(FirstName=nameParts[0],
                                            LastName=nameParts[1],
                                            Email=caseObj.SuppliedEmail,
                                            Phone=caseObj.SuppliedPhone,
                                            Autocreated__c=true);
                emailToContactMap.put(caseObj.SuppliedEmail,cont);
                casesToUpdate.add(caseObj);
            }
        }
    }
    List<Contact> newContacts = emailToContactMap.values();
    insert newContacts;
    for (Case caseObj:casesToUpdate) {
        Contact newContact = emailToContactMap.get(caseObj.SuppliedEmail);
        caseObj.ContactId = newContact.Id;
    }
}
 
  • October 05, 2016
  • Like
  • 1