+ Start a Discussion
Internal PartnerInternal Partner 
Hi all,

I am struggling trying to fix a test class for an APEX class (WSDL) which has the following form:
 
global class Example {
   webService static String getUserName(String name) {
       return UserInfo.getUserEmail();
   }
}

My test class is this:
 
@isTest
private class Example_Test {
    @isTest static void Example() {              
        // This causes a fake response to be generated
        Test.setMock(WebServiceMock.class, new getUserName());  
    }
}

I am getting this error:
 
System.TypeException: Mock object doesn't implement the supplied interface
Class.System.Test.setMock: line 57, column 1
Class.Example_Test.Example: line 5, column 1
Any advice would be appreciated :)
 
Best Answer chosen by Internal Partner
Raj VakatiRaj Vakati
My mistake pls 


try the below code its 100%

 
@isTest
public class ExampleTest {
    static testMethod void testMyWebSvc()
    {
        Profile pf= [Select Id from profile where Name='System Administrator']; 
        
        String orgId=UserInfo.getOrganizationId(); 
        String dateString=String.valueof(Datetime.now()).replace(' ','').replace(':','').replace('-','') ;
        Integer RandomId=Integer.valueOf(Math.rint(Math.random()*1000000)); 
        String uniqueName=orgId+dateString+RandomId; 
        User uu=new User(firstname = 'ABC', 
                         lastName = 'XYZ', 
                         email = uniqueName + '@test' + orgId + '.org', 
                         Username = 'testasdafsghdfgasf@gam.com', 
                         EmailEncodingKey = 'ISO-8859-1', 
                         Alias = uniqueName.substring(18, 23), 
                         TimeZoneSidKey = 'America/Los_Angeles', 
                         LocaleSidKey = 'en_US', 
                         LanguageLocaleKey = 'en_US', 
                         ProfileId = pf.Id
                        ); 
        
        
        insert uu;
        System.runAs(uu){
            
            Test.startTest();
            Example.getUserName('testasdafsghdfgasf@gam.com') ;
            Test.stopTest();
        }
    }
}

 
Frank CarterFrank Carter 
Hello,
I need help. I have a method that receives a list of custom object. In this object there is a date field already valued. I want update only the month of this date with the current month.
I tried with:
Integer m = Date.Today().Month();

 for(Custom_Object__c co: selectedCO) {
                                 
           co.date__c.Month()=m;

Error: Expression cannot be assigned

Can Someone hepl me?


Thanks,
Francesco
Best Answer chosen by Frank Carter
Alain CabonAlain Cabon
Hi,

newInstance(year, month, date) (static): Constructs a Date from Integer representations of the year, month (1=Jan), and day.

 co.date__c = Date.newinstance(  co.date__c.year() , m ,  co.date__c.day() );
mahesh p 54mahesh p 54 
<apex:page controller="PassportController" >    
    
    
    
    <div class="slds-vertical-tabs">
  <ul class="slds-vertical-tabs__nav" role="tablist" aria-orientation="vertical">
    <li class="slds-vertical-tabs__nav-item slds-is-active" title="Tab 1" role="presentation"><a class="slds-vertical-tabs__link" href="javascript:void(0)" role="tab" tabindex="0" aria-selected="true" aria-controls="slds-vertical-tabs-0" id="slds-vertical-tabs-0__nav">Applicant Details</a></li>
    <li class="slds-vertical-tabs__nav-item" title="Tab 2" role="presentation"><a class="slds-vertical-tabs__link" href="javascript:void(0)" role="tab" tabindex="-1" aria-selected="false" aria-controls="slds-vertical-tabs-1" id="slds-vertical-tabs-1__nav">Family Details</a></li>
    <li class="slds-vertical-tabs__nav-item" title="Tab 3 has a really long label and can wrap or truncate"
      role="presentation"><a class="slds-vertical-tabs__link" href="javascript:void(0)" role="tab" tabindex="-1" aria-selected="false" aria-controls="slds-vertical-tabs-2" id="slds-vertical-tabs-2__nav">Tab 3 has a really long label and can wrap or truncate</a></li>
  </ul>
  <div class="slds-vertical-tabs__content slds-show" id="slds-vertical-tabs-0" role="tabpanel" aria-labelledby="slds-vertical-tabs-0__nav">
    <div class="slds-text-longform">
      <h3 class="slds-text-heading_medium">Applicant Details</h3>
     <apex:form >
        <apex:pageMessages />
        <apex:pageBlock title="Applicant Details" >

            <apex:pageBlockSection columns="1" title="Applicant Details Information" > 
                <apex:inputField value="{!p.Name}"/>
                <br/>
                <apex:inputField value="{!p.Gender__c}"/>
                <apex:inputField value="{!p.Date_of_Birth_DD_MM_YYYY__c}"/>
                <apex:inputField value="{!p.Place_of_Birth_Village_Town_City__c}"/>
                <apex:inputField value="{!p.Marital_Status__c}"/>
                <apex:inputField value="{!p.PAN_if_available__c}"/>
                <apex:inputField value="{!p.Voter_Id_if_available__c}"/>
                <apex:inputField value="{!p.Educational_qualification__c}"/>
                <apex:inputField value="{!p.Aadhaar_Number_if_available__c}"/>
            </apex:pageBlockSection>
            
            
            
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>

        </apex:pageBlock>
        
    </apex:form>
    </div>
  </div>
  <div class="slds-vertical-tabs__content slds-hide" id="slds-vertical-tabs-1" role="tabpanel" aria-labelledby="slds-vertical-tabs-1__nav">
    <div class="slds-text-longform">
      <h3 class="slds-text-heading_medium">Family Details</h3>
      <p>Content for Tab 1</p>
      <p>Lorem ipsum dolor...</p>
      <p>Lorem ipsum dolor...</p>
    </div>
  </div>
  <div class="slds-vertical-tabs__content slds-hide" id="slds-vertical-tabs-2" role="tabpanel" aria-labelledby="slds-vertical-tabs-2__nav">
    <div class="slds-text-longform">
      <h3 class="slds-text-heading_medium">Tab Title</h3>
      <p>Content for Tab 1</p>
      <p>Lorem ipsum dolor...</p>
      <p>Lorem ipsum dolor...</p>
    </div>
  </div>
</div>
</apex:page>

 
Best Answer chosen by mahesh p 54
Khan AnasKhan Anas (Salesforce Developers) 
Hi Mahesh,

Greetings to you!

Please refer to the below link which might help you with the above requirement.

http://www.minerva18.com/blog/creating-switchable-lightning-design-tabs-in-salesforce/

https://developer.salesforce.com/forums/?id=906F00000005JHzIAM

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas
丹 朱丹 朱 
I have tried to add a custom visualforce page into the Standard Page Layout.
And it works in The Update-Page and Detail-Page.
But does not work in the New-Page.
I can not find out why the custom visualforce page could not show in the New-Page.
How to set the setting can do it?
Best Answer chosen by 丹 朱
SandhyaSandhya (Salesforce Developers) 
Hi,

Visualforce pages only appear in detail mode. You'll need to write up an entire Visualforce page if you really need to override the new record page.

https://salesforce.stackexchange.com/questions/73096/how-to-make-an-in-line-visualforce-page-to-be-displayed-in-the-new-lead-standard
 
 Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 

  
Ami PandaAmi Panda 
 <a><lightning:icon aura:id="icon1" class="icon_chat" size="small" iconName='utility:chat' /></a>

User-added image
Best Answer chosen by Ami Panda
Khan AnasKhan Anas (Salesforce Developers) 
Hi Ami,

Greetings to you!

Use below CSS:
 
.THIS .icon_chat svg {
    fill : blue;
}


Please refer to the below links for more information:

http://sfdcmonkey.com/2017/12/22/change-lightningicon-color/

https://salesforce.stackexchange.com/questions/147153/lightning-icon-color-is-not-changing-using-the-fill-css?rq=1

https://developer.salesforce.com/forums/?id=9060G000000XefKQAS



I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas
Baron Chen 11Baron Chen 11 
User-added image
When I Create a package version, I get an error:

sfdx force:package:version:create -n 1.1.0.1 -d force-app -x --wait 10
User-added image

 
Best Answer chosen by Baron Chen 11
SandhyaSandhya (Salesforce Developers) 
Hi,

Did you change the version in sfdx-project.json.

I would suggest you refer below trailhead module which have the steps to create package version.

https://trailhead.salesforce.com/en/modules/unlocked-packages-for-customers/units/build-your-first-unlocked-package
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
Sneha KathavateSneha Kathavate 
Hi All,

I am relatively new to Apex coding. I have written a class which is giving the error "Missing return statement required return type: Boolean". Could you plz  help me resolve this .

public class CC_JobBoardApp_checkstatus {
    @AuraEnabled
    public static Boolean checkstatus()
    {
        Set<Id> jobid = new Set<Id>() ;
            for(TR1__Job_Board_Application__c jba : 
                [SELECT TR1__Status__c,TR1__Job__c,Job_Id__c    
                 from TR1__Job_Board_Application__c 
                 where Id in :JobId
                 LIMIT 1])
            if(jba.TR1__Status__c=='Rejected')
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}


The class checks if the status of the job application is rejected. If it is rejected, then returns true else returns false. 
Best Answer chosen by Sneha Kathavate
Ajay K DubediAjay K Dubedi
Hi Sneha,

You can do it in the following way. Hope this works for you.


public class CC_JobBoardApp_checkstatus {

    @AuraEnabled
    public static Boolean checkstatus()
    {
    public boolean isRejected = false;
        Set<Id> jobid = new Set<Id>() ;
            for(TR1__Job_Board_Application__c jba : 
                [SELECT TR1__Status__c,TR1__Job__c,Job_Id__c    
                 from TR1__Job_Board_Application__c 
                 where Id in :JobId
                 LIMIT 1])
            if(jba.TR1__Status__c=='Rejected')
        {
            isRejected = true;
        }
       return isRejected;
    }
}

Thank You
Ajay Dubedi
Nasir SiddiquiNasir Siddiqui 
Hi,

Can someone please  advise what permissions are needed to enable the edit functionality on Email Alert for a user other then system admin

Thanks,
Nasir

 
Best Answer chosen by Nasir Siddiqui
Raj VakatiRaj Vakati
Customize application permission is required 
Harjinder AhluwaliaHarjinder Ahluwalia 
Hi 
I am calling a datatable from the action button on the detail page, the pop window width is very less, i want to increase it to.
Please complete full procedure how can i fix this problem.
Thanks
Best Answer chosen by Harjinder Ahluwalia
Alain CabonAlain Cabon
Hi, 

1) Create this static resource: popupCSS
 
.slds-modal__container{
    max-width: 70rem !important;
    width:80% !important;
}

2) Use this new static resource with <lng:require> at the beginning of your component
 
<aura:component controller="MyCrtrl"implements="force:lightningQuickAction,force:appHostable,force:hasRecordId,force:hasSObjectName">
   <ltng:require styles="{!$Resource.popupCSS}" />
Rajat Bhatt 4Rajat Bhatt 4 
Hi,
I am new to salesforce and i am facing an issue my Trigger is not working properly.
I want the trigger to check whether the all Shipping Address field is filled or not , and if not the display the error message.
Any help will be appreciated.
Thanks.
trigger shippingAddress on Account (before insert,before update)
{

    List<Account> accList=new List<Account>();
    
    for(account accObject:trigger.new)
    {
        if(accObject.ShippingStreet !=null && accObject.ShippingCity!=null &&
           accObject.ShippingState!=null && accObject.ShippingPostalCode!=null && 
           accObject.ShippingCountry!=null)
        {
           accList.add(accObject);
        
        }
        
        else
        {
        
            accObject.addError('All Shipping Fields are required');
            
        }

    }
    
    insert accList;
}

 
Best Answer chosen by Rajat Bhatt 4
Ajay K DubediAjay K Dubedi
Hi Rajat,

Hi have done some small changes to your trigger. Hope this will work for you.

trigger shippingAddress on Account (after insert,after update)
{
    try{
    List<Account> accList=new List<Account>();
    
    for(account accObject:trigger.new)
    {
        if(accObject.ShippingStreet ==null || accObject.ShippingCity ==null ||
           accObject.ShippingState ==null || accObject.ShippingPostalCode==null || 
           accObject.ShippingCountry==null)
        {
           
        accObject.addError('All Shipping Fields are required');
        }
        
        else
        {
        
            accList.add(accObject);
            
        }

    }
    
    insert accList;
    }catch(Exception exp){
        system.debug('The following exception has occurred ' + exp.getMessage() + ' at line no ' + exp.getLineNumber());
    }
}

Thank you
Ajay Dubedi