• GhanshyamChoudhari
  • SMARTIE
  • 961 Points
  • Member since 2018

  • Chatter
    Feed
  • 30
    Best Answers
  • 0
    Likes Received
  • 4
    Likes Given
  • 0
    Questions
  • 212
    Replies
Hi.
I have 2 questions. It is possible to have a field in read only until some other field is fill with certain value? And related, it is possible hide or not hide a field with that logic?

Thanks in advance
Hi All,

I was reading through the apex guide and i came across the statement which actually i didnt understand.
Could you please explain me that.

"The @isTest annotation can take multiple modifiers within parentheses and separated by blanks."

What does is mean here .An example /scenario would actually help.

Thanks a lot in advance!

Deepshikha
How to find contacts which do not have cases, opportunities, activities, etc so that we can delete such contacts from the database? 
Thanks in advance.

Yogesh

 
I new to Apex, and failing miserably.  Time and time again and I cannot come up with anything beyond 0% code coverage.  I have the following trigger:
trigger leadDuplicatePreventer on opportunity(before insert) {
   set<string> settgs = new set<string>();
   list<opportunity> opps = [select id,Trigger_Help__c  from opportunity WHERE CreatedDate = LAST_N_DAYS:90];
   Profile p=[SELECT ID, Name FROM Profile WHERE Id=:userinfo.getProfileId() Limit 1];
   for(opportunity opp : opps){
     if(opp.Trigger_Help__c != null && p.Name <> 'System Administrator'){
	 settgs.add(opp.Trigger_Help__c);
	 }
   }
   
   for(opportunity op : trigger.new){
      if(settgs.contains(op.Trigger_Help__c)){
	     op.adderror('An Opportunity of this type already exists on this Account.  Please contact a system administrator with questions.');
	  }
   
   }


   
}

The Trigger_Help__c is a formula field that combines Oppty_Type__c+Account Id.  These 9 lines are all I have to figure out and I cannot get this for the life of me.  My current test class is as follows:

@isTest
private class TestleadDuplicatePreventer {
    @isTest static void TestleadDuplicatePreventerwithOneOpp() {
    Account acct = new Account(Name='Test Account');
    insert acct;
    Opportunity opp = new Opportunity(Name=acct.Name + ' Opportunity',
                                     StageName='Open Opportunity',
                                     CloseDate=System.today().addMonths(1),
                                     Facility__c='Tacoma WA',
                                     Oppty_Type__c='UCO Service',
                                     AccountID=acct.Id);
    insert opp;
    Test.startTest();
    opp= new Opportunity(Name='Opportunity Test',
                        StageName='Open Opportunity',
                        CloseDate=System.today().addMonths(2),
                        Facility__c='Tacoma WA',
                        Oppty_Type__c='UCO Service',
                        AccountId=acct.Id);
    try
    {
        insert opp;
    }
    catch(Exception duplicate)
    {       
       System.assertEquals('An Opportunity of this type already exists on this Account.  Please contact a system administrator with questions.', duplicate.getMessage());
    }
    //this should probably be in a separate test method
    Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
  User u2 = new User(Alias = 'newUser', Email='newuser@testorg.com',
     EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
     LocaleSidKey='en_US', ProfileId = p.Id,
     TimeZoneSidKey='America/Los_Angeles', UserName='newuser@testorg.com');

  System.runAs(u2) {
      insert opp;
  }
        Test.stopTest();}}
But I have also been trying and failing with the following test class:
 
@isTest
public class TestleadDuplicatePreventer {
    static testMethod Void TestleadDuplicatePreventerwithOneOpp() {
        User u1 = [SELECT Id FROM User WHERE Alias='jmilt'];
        System.runAs(u1){
        Account acct = new Account(Name='Test Account');
        insert acct;
        Opportunity opp1 = new Opportunity(Name=acct.Name + ' Opportunity',
                                         StageName='Open Opportunity',
                                         CloseDate=System.today().addMonths(1),
                                         Facility__c='Tacoma WA',
                                         Oppty_Type__c='UCO Service',
                                         AccountID=acct.Id);
        Opportunity opp2 = new Opportunity(Name=acct.Name + ' Opportunity1',
                                          StageName='Open Opportunity',
                                          CloseDate=System.today().addMonths(1),
                                          Facility__c='Tacoma WA',
                                          Oppty_Type__c='UCO Service & Indoor Equipment',
                                          AccountID=acct.Id);
        Opportunity opp3 =  new Opportunity(Name=acct.Name + ' Opportunity2',
                                           StageName='Open Opportunity',
                                           CloseDate=System.today().addMonths(1),
                                           Facility__c='Tacoma WA',
                                           Oppty_Type__c='Trap Service',
                                           AccountID=acct.Id);
            Opportunity[] opps = new Opportunity [] {opp1, opp2, opp3};
            insert opps;
            
        Opportunity dup1 = new Opportunity(Name='Check',
                                          StageName='Open Opportunity',
                                          CloseDate=System.today().addMonths(1),
                                          Facility__c='Tacoma WA',
                                          Oppty_Type__c='UCO Service',
                                          AccountID=acct.Id);
            Test.startTest();
        try
        {
            insert dup1;
        }
        catch(Exception duplicate)
        {    
            System.assertEquals('An Opportunity of this type already exists on this Account.  Please contact a system administrator with questions.', duplicate.getMessage());

        }}
   Test.stopTest(); }

}

If anyone is out there who can help it would be greatly appreciated!

I am trying to hide a contact tab from the nav bar for the end user.
surpisingly the contact tab is not included in nav bar but still its appearing on the nav bar(with *).
when I try to close the tab & relogin its appearing again.
Please let me know if I am missing any setting
Hi All,

I cam across a scenario while making my functionality in lightning a managed package. 

Before having a namespace, my functionality was wrking fine where I was able to receive the attributes from another component in the init method perfectly fine when the component was dynamically created. 

this attributes stopped coming in child when I create a namespace

Any clues ?
 
When creating a lighting action (with action type as Custom Visualforce or Lightning Component), there is no provision to specify the width (of the modal pop-up). While this can be achived by including custom CSS to the class 'slds-modal__container', I'm not sure if that's the right way to go. Im assuming here that Salesforce or Lightning platform first defines width of the modal pop-up and then resizes contents within according the to the outer HTML element width. If we apply custom CSS, then it will most possibly act on the Outer HTML but not on all of the inner content. is my assumption correct? If yes, then what is the right way to achieve modifying the modal pop-up width?
Hi,

I have a batch class running, which allocates sales rep based on the the zip code assigned.

My problem here is , It is running for one profile , but not running for other. .

Is there something in configuration , that I am missing ? Please advise 

 
I am logged into my DE account as system administrator and I am trying to import excel data into a custom object with data import wizard, but I get this prompt when I click on Custom Object.  This has never happened before, have I accidentally turned a permission off?  Where do I go to edit my permission for data import?  Thanks!


User-added image
I created a very basic Trigger:

trigger HelloWorld on Lead (before update) {
    for (Lead L : Trigger.new) {
    L.FirstName = 'Hello';
    L.LastName  = 'World';
  }
}

When I create a new Lead record in Classic, it works as expected (ie, no change since it should fire only in Update) but when I create a new Lead record in Lightning, as soon as I save, the first and last name gets updated to Hello World.

This is a brand new developer Org and so there are no other triggers etc. Has anyone else run into this problem?
I want to display all the cases with have attachments in a table along with the File name and other file related information in lighting component