• Preyanka
  • NEWBIE
  • 274 Points
  • Member since 2015

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 30
    Replies
User objet in salesforce has a field 'Admin Info Emails'. This field is checkbox. In our org, the users of same profile(customer service profile), this field has different status for different users(of same profile). How to edit this button?
Thanks in advance
Which three declarative fields are correctly mapped to variable types in Apex?

Choose 3 answers.

A. Checkbox maps to Boolean
B. Number maps to Integer
C. Date/Time maps to Datetime
D. TextArea maps to List of type String
E. Number maps to Decimal
 
I want to migrate library contents from one salesforce org to another salesforce org.
I was able to do it using data loader and making local copies of content.
This is good for less number of contents but not good for large number of contents as it requires manual intervention.

Please suggest some automatic easy-to-use way to do this.
Hi Please help write test class and get code coverage for my class

Class:-
public class IssuersCalloutController{

    public IssuersCalloutController(ApexPages.StandardController controller) {

    }


public PageReference saveCalloutResult(){
         
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://test/getIssueList');
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept','application/json');
         system.debug('request endpoint '+ req);    
        String username = 'amit';
        String password = 'password';
        
        Blob headerValue= Blob.valueOf(username + ':' + password);
        system.debug('headerValue'+ headerValue);
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        req.setTimeout(60000);
        
        system.debug('###req### '+ req);            
        HttpResponse res = h.send(req);
        system.debug('###res### '+ res);
        
        string response = res.getBody();
        system.debug('response'+ response);
               
                
        Set<String> bankNames = New Set<String>();
        // declare issuer list to inser 
        List<Issuers__c> InsertedIssuers = New List<Issuers__c>();
        // I used limit in below query, but its better to use any filter to limit the data
        for(Issuers__c issuer : [Select Id,Bankdir_Name__c from Issuers__c LIMIT 50000]){
           If(!string.isBlank(issuer.Bankdir_Name__c)){
             bankNames.add(issuer.Bankdir_Name__c);
             
             //system.debug('###Bank Name### '+ bankNames); 
             //system.debug('issuerbankdir'+ issuer.Bankdir_Name__c);
            }
        }
        system.debug('###Bank Name### '+ bankNames.size());
        List<JsonParserDetail> responseDetails = JsonParserDetail.parse(response); 
        system.debug('****responseDetails****** '+responseDetails);
        
        if(responseDetails.size() > 0){
            for(JsonParserDetail jpd : responseDetails){
                If(!bankNames.contains(jpd.issuerBankdirName)){                
                 InsertedIssuers.add(getIssuer(jpd.issuername,jpd.issuerBankdirName,jpd.processorName,jpd.subProcessorName,jpd.siloName));
                }
            }
        }
        If(InsertedIssuers.size() >0){
            insert InsertedIssuers;
            
      
        }
        PageReference p = apexPages.currentPage();
      ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.CONFIRM,'Preview 2 list Successfully updated'+InsertedIssuers.size()+'"Thank you!');
      ApexPages.addMessage(msg);
      return p;
    }
  public Issuers__c getIssuer(string iName, string ibName, string pName, string spName,string siloName){
        Issuers__c issuer = New Issuers__c();
        issuer.Name = iName;
        issuer.Bankdir_Name__c = ibName;
        issuer.Processor_Name__c = pName;
        issuer.SubProcessor_Name__c = spName;
        issuer.Silo_Name__c = siloName;
        return issuer;
    }
}

Thanks
I needed a trigger to create clone of account record on insert.
To avoid recursion I have used a boolean. Is there any method to stop recursion that can be used in this place.
-------------------------------------------------------------------------------------
public class CloneAccountTriggerHandler {
public static Boolean cloneRecord = true;
/**
Method : cloneAccountRecord
Type : Test Method
Description : Method To create Clone of Account Record when inserted
*/
public static List<Account> cloneAccountRecord(List<Account> newAccount){
List<Account> listAccount = new List<Account>();
if(cloneRecord) {
System.debug(newAccount);
cloneRecord = false;
for(Account account : newAccount) {
listAccount.add(account.clone(false));
}
Database.insert(listAccount,false);
}
return listAccount;
}
}
trigger studentcount1 on Student__c (after insert,after update,after delete,after  undelete) {
    set<ID> parentID=new set<ID>();
    List<Teacher__c> ParentQueryList=new list<Teacher__c>();
    List<Teacher__c> ParentToupdate=new list<Teacher__c>();
    If(Trigger.isinsert|| Trigger.isupdate||Trigger.isundelete)
    {
    for(student__c acc:Trigger.new)
    {
        if(acc.subject__r.id!=null)
        {
        parentID.add(acc.subject__r.id);
        }
    }
    }
    If(Trigger.isdelete){
        for(student__c acc:Trigger.old)
        {
           if(acc.subject__r.id!=null)
        {
        parentID.add(acc.subject__r.id);
        } 
            
        }
    }
      if(parentID.size()>0)
      
    ParentQueryList=[select id,name,childcount__c,(select id,name,subject__c from students__r) from Teacher__c where ID in :parentID];
   system.debug('ParentQueryList--->'+ParentQueryList);
   
    for(Teacher__c tc:ParentQueryList)
    {
        tc.childcount__c=tc.students__r.size();
        ParentToupdate.add(tc);
    }
    if(ParentToupdate.size()>0)
    {
    update ParentToupdate;
    }
  
    
        
         
        
        
 

}
Hi guys,

I'm having a bit of a nightmare using data loader to mass upload records to a custom object. I have extracted data from one custom object and I'm uploading the data into another object.

The field is question is Quantity__c and both are of type number with a length of 18 and 0 decimal places. I have changed the format in the .csv file to reflect this but it just is not accepting the data.

Has anyone faced a similar issue and if so how did you resolve it?
Hi Team,

How can we bulkify this using trigger handler class, please let me know any one.
Trigger :
---------------
trigger OpportunityTrig on Opportunity (before insert, before update, after insert, after update) {
    
    
    if(Trigger.isBefore && Trigger.isInsert){
        
  for(opportunity op : Trigger.New){
            //opportunity o = Trigger.oldmap.get(op.Id);
            if(op.Close_Deal_Date__c != null){
                
                
                Integer y = op.Close_Deal_Date__c.YEAR();
                Integer m = ((op.Close_Deal_Date__c.MONTH()-1)/3)+1;
                String q = String.valueOf(y)+' Q'+String.valueOf(m);
                system.debug('y'+y+' Mon :'+m+' Quarter:'+q);
                op.Reporting_Quarter__c = q;
            }
            else if(op.Close_Deal_Date__c == null){
                op.Reporting_Quarter__c = null;
            }
            
            
        }

    }
    
    if(Trigger.isBefore && Trigger.isUpdate){
       OpportunityTriggerHandlerCls.oppCategoryUpdate((List<Opportunity>)Trigger.New);
        for(opportunity op : Trigger.New){
            opportunity o = Trigger.oldmap.get(op.Id);
            if(op.Close_Deal_Date__c != null && (op.Close_Deal_Date__c != o.Close_Deal_Date__c)){
                
                
                Integer y = op.Close_Deal_Date__c.YEAR();
                Integer m = ((op.Close_Deal_Date__c.MONTH()-1)/3)+1;
                String q = String.valueOf(y)+' Q'+String.valueOf(m);
                system.debug('y'+y+' Mon :'+m+' Quarter:'+q);
                op.Reporting_Quarter__c = q;
            }
            else if(op.Close_Deal_Date__c == null && (op.Close_Deal_Date__c != o.Close_Deal_Date__c)){
                op.Reporting_Quarter__c = null;
            }
            
        }
    }
}

I want to bulkify this code using trigger handler class.


Regards,
Lakshmi
 
I have 10000 records  in contact object and 5000 of them are duplicate contact lastname.

My requirement is to eliminate the duplicates lastnames in contact object.

I have soql script which unfortunately doesnt work.

List<Contact> conList=[select ID,LastName from contact LIMIT 50000];   
Map<String,contact> conMap=new Map<String,Contact>();

for(Contact c:conList)
{
   conMap.put(c.LastName,c);
}

//at this point the map should merge the duplicates.  Please correct my understanding

Now datbase.update(conMap.values());

But once update statement is executed, the duplicate records still exists. Only the map has the updated records.

Please let me know if this approach is right....

thanks
sheila




 
I have 2 custom objects: Student and Registration.They have a same field class. Registration has a lookup to Student. I need to update all related registration records's class field when the class of student is updated using triggers. (A student can have multiple registrations)
Thanks in advance.
The Contact object already has two lookup fields to User: Created By and Owner. I would like to add a third that will be used to indicate responsibility for for marketing activities.  In other words, a Contact will be owned by someone - someone who is a field based salesperson - yet will have someone who is assigned from the Inside Sales team to communicate with the Contact for other issues. Looks like I am unable to do that because adding the lookup would be a third lookup to the User object.

I can use a junction object but that will make things significantly more complicated. Does anyone have a workaround or idea to make this work? Am I missing something?
Hi,

I am using visualforce page(not lightning component) and in the page I use slds modal. When I click a button in the page it will open the modal above the page and the parent page greyed out. I want to pass some field values of parent page to modal. Can any one help how to do that. Modal is working fine but want a idea to pass value to modal.

<apex:slds /> <script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<!--Button-->
<button class="slds-button slds-button--brand" id="toggleBtn" onclick="openModal(); return false;">Find</button>

<div class="search">
            <div class="slds-modal" aria-hidden="true" role="dialog" id="modal">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Search</h2>
                    </header>
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <div class="modal-body" id="modBody">
                            <table class="slds-table slds-table_bordered slds-table_cell-buffer">                               
                                <tr>                                    
                                    <td>
                                        Zip code:
                                    </td>
                                    <td>
                                        <apex:inputText value="{!inputZipCode}" id="txtZipCode" maxlength="9" />
                                    </td>
                                </tr>                                 
                            </table>
                        </div>
                    </div>
                  
                    <footer class="slds-modal__footer">
                        <button class="slds-button slds-button_neutral" onclick="closeModal()">Cancel</button>
                        <apex:commandButton value="Search" reRender="modResult, modres" />
                    </footer>
                </div>
            </div>
            <div class="slds-backdrop" id="backdrop"></div>
        </div>
            <!-- Modal Toggle Script -->
        <script>
            j$ = jQuery.noConflict();
            
            //Modal Open
            function openModal(){
              j$('#backdrop').addClass('slds-backdrop--open');
              j$('#modal').addClass('slds-fade-in-open');
            }
            
            //Modal Close
            function closeModal(){
              j$('#modal').removeClass('slds-fade-in-open');
              j$('#backdrop').removeClass('slds-backdrop--open');
            }
        </script> 

Hello,

I need to calculate hours between two DateTime objects in apex excluding non-working days and weekends. Here is my method:
// calculate working hours between createdDate and completedDate
private Integer calculateWorkingHours(Datetime createdDate, Datetime completedDate) {
    List<BusinessHours> bhList = [Select id From BusinessHours Where IsDefault=true];
    if(bhList.size() == 0) {
        //If there is a problem to get hours from the BusinessHours database table return -1
        return -1;
    }

    // Get id of used set of business hours
    String bhId = bhList.get(0).id;

    // Returns the difference in milliseconds between a start and end Datetime based on a specific set of business hours.
    System.debug('createdDate ' + createdDate);
    System.debug('completedDate ' + completedDate);
    Long businessMillis = BusinessHours.diff(bhId, createdDate, completedDate);
    //Convert milliseconds to hours
    System.debug('businessMillis ' + businessMillis); 
    Integer bHours = (Integer)((businessMillis/1000)/60)/60;
    System.debug('bHours ' + bHours);
    return bHours;
}
And the data from the BusinessHours database table:

User-added image

Method 
BusinessHours.diff()
is calculating the Saturday and Sunday such as 24 hours working days!

How do I change Saturday and Sunday to be non-working days, hence zero working hours?
trigger casePhone on Account (After insert,After update) {
    for(Account a : trigger.new){
    list<case> kca = New list<case>([select id,ContactMobile from case where ContactMobile != null And Accountid =: a.id]);
    for(case ca : kca){
        ca.ContactMobile = a.Phone;
        
    }
  }  
}
Hello all !
I am new to SFDC, so I could use some help

I have to custom objects
Product Move and Deliveries
I want a trigger that makes a delivery when I make an order
with the delivery named after my product move
trigger ProductMoveTrigger on Product_Move__c ( after insert) {

    List<Delivery__c> deliveries= new List<Delivery__c>();

    for(Product_Move__c c : Trigger.new)
    {
        Delivery__c d = new Delivery__c();
        d.Name = c.Store__c + c.Product__c;

        deliveries.add(d);
    }

    try {
        insert deliveries;
    } catch (system.Dmlexception e) {
        system.debug (e);
    }   
}

where am I going wrong?

Thanks for the help