• Ajay K Dubedi
  • ALL STAR
  • 7874 Points
  • Member since 2015
  • Ajay Dubedi


  • Chatter
    Feed
  • 252
    Best Answers
  • 0
    Likes Received
  • 7
    Likes Given
  • 1
    Questions
  • 1951
    Replies
I have the following Apex class and VF page.  Based on the selection of the tite, the corresponding role should display. I am using the actionSupport to pass the selected value onchange event, and assign the value to selectedTitle. But the selectedTitle is null everytime. Any ideas?

Apex class:
public class selectListController
{
    public String title { get; set; }
    public String role { get; set; }    
    public String selectedTitle { get; set; }        
    public List<selectOption> titleList { get; set; }
    public List<selectOption> roleList { get; set; }
    
    public selectListController()
    {
        titleList = new List<selectOption>();
        titleList.add(new SelectOption('', '--None--'));
        for (TitleRoleAssociation__c title : [Select Title_Definition__r.Name from TitleRoleAssociation__c]) {
            titleList.add(new selectOption(title.Title_Definition__r.Id, title.Title_Definition__r.Name));
        }
    }
    
    public PageReference getRoles(){
        roleList = new List<selectOption>();
        roleList.add(new SelectOption('', '--None--'));
        System.debug('Selected title: ' + selectedTitle);
        for (TitleRoleAssociation__c role : [Select Role_Definition__r.Name from TitleRoleAssociation__c where Title_Definition__r.Name = :selectedTitle]) {
            roleList.add(new selectOption(role.Role_Definition__r.Id, role.Role_Definition__r.Name));
        }
    
        return null;
    }
    
}

VF page:
<apex:page controller="selectListController">
    <apex:form>
        <apex:selectList value="{!title}" multiselect="false" size="1">
            <apex:selectOptions value="{!titleList}" />
            <apex:actionSupport event="onchange" action="{!getRoles}" reRender="role" status="status">                         
               <apex:param name="selectedTitle" value="{!title}" assignTo="{!selectedTitle}"/>
            </apex:actionSupport>            
        </apex:selectList>

        <apex:outputPanel id="role">
        <apex:selectList value="{!role}" multiselect="false" size="1">
            <apex:selectOptions value="{!roleList}" />
        </apex:selectList>        
        </apex:outputPanel>
    </apex:form>
</apex:page>
 
Hi All,

I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
public class TodayTelesalesDetails {

public Date Today { 
    get { 
        return Date.today(); 
    }
}
public List<wrapAgent> wrapAgentList{get; set;}
public List<User> selectedAgents{get;set;}

public TodayTelesalesDetails (){
   
    if(wrapAgentList == null) {
        wrapAgentList = new List<wrapAgent>();

        for(User teleSalesAgent: [select Id, Name, Email from User where Name IN('Steve Waugh','Yuvraj Singh')]) {
            // As each agent is processed we create a new wrap object and add it to the wrapAgentList
            wrapAgentList.add(new wrapAgent(teleSalesAgent));
    }
}
}

public PageReference doFullSave(){

    set<id> userSetId = new set<id>();
    list<GroupMember> gmm = new list<GroupMember>();
    List<GroupMember> toBeDeleted= [SELECT Id, GroupId, UserOrGroupId FROM GroupMember where GroupId = '00G9D000000toPYUAY'];
    delete toBeDeleted;
    List<User> userlist=[select Id, Name from User where Name IN('Steve Waugh','Yuvraj Singh')];
   
    for(User u : userlist)
    { 
    system.debug('message3>>'+u);
         for(wrapAgent wrapAccountObj : wrapAgentList) {
             
            if(wrapAccountObj.selected == true) {
                userSetId.add(wrapAccountObj.teleAgent.id);
                
            }
        }

    }
      
    for(User us : [select id from User where id =: userSetId])
    {
       
        for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue'])
        {
            GroupMember gm = new GroupMember();
            gm.groupId = gg.id;
            gm.UserOrGroupId = us.Id;
            gmm.add(gm);
        }
        
    }
            
     
    insert gmm;
    PageReference pageRef = new PageReference('/');
            pageRef.setRedirect(true);
            return pageRef;
    }
   
   
    
 public PageReference doCancel(){
         
         PageReference pageRef = new PageReference('/');
            pageRef.setRedirect(true);
            return pageRef;
    }


 public class wrapAgent{
    public User teleAgent {get; set;}//Please put the custom metadata names
    public Boolean selected {get; set;}


    //This is the contructor method. When we create a new object we pass a telesales metadata member that is set to the acc property. We also set the selected value to false
    public wrapAgent(User teleSalesAgent) {
        teleAgent = teleSalesAgent;
        selected = false;

    }
}
}
and below is my test class:
@isTest
public class Test_TodayTeleSalesDetails {

    public static testMethod void validateusersinqueue() {
    Group testGroup = new Group(Name='test group', Type='Queue');
	insert testGroup;

	System.runAs(new User(Id=UserInfo.getUserId()))
	{
    QueuesObject testQueue = new QueueSObject(QueueID = testGroup.id, SObjectType = 'Lead');
    insert testQueue;
	}
   	Test.startTest();
     TodayTelesalesDetails telesalesDetails=new TodayTelesalesDetails();
       telesalesDetails.doFullSave();
        telesalesDetails.doCancel();
    Test.stopTest();
}
}

I am not able to cover below lines of code:
for(User us : [select id from User where id =: userSetId])
    {
        system.debug('message6>>'+us);
        for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue'])
        {
            GroupMember gm = new GroupMember();
            gm.groupId = gg.id;
            gm.UserOrGroupId = us.Id;
            gmm.add(gm);
        }
        
    }
Below is the screenshot for the same:
Lines of Code is not covering
My current code coverage stands at 73%

Many I request to help me on same to get a code coverage above 75%

Many thanks in advance

Thanks & Regards,
Harjeet
Hi Guys,

In my ORG, I have two custom objects named as follows.

Here Warehouse is Parent Object and Product is Child object.

Also, master-detail relation ship has created with Product_Warehouse_Location field in Product object

Custom Objects

But I'm trying to retrive the record using child to parent  relationship SOQL queries between the objects

SOQL Query
I'm getting  the following error in Query editor window.

Product_Warehouse_Location__c, Product_Name__c ,Warehouse__r.Name FROM Product__c
                                                ^
ERROR at Row:1:Column:65
Didn't understand relationship 'Warehouse__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.



Please someone help me on this. Help to identify whats wrong with my query.

Custom Object Parent API Name : Warehouse__c
Fields:
Name
Warehouse_Name__c
Warehouse_Location__c

Custom Obejct Child API Name : Product__c
Fields:
Name
Product_Name__c
Product_Warehouse_Location__c ---Master-Detail(Warehouse)



 
public class CustomEmailComponentHandler {
    @AuraEnabled
    public static User getUserInfo() {
        try{
            User UserObj = [SELECT Name,Email 
                            FROM User 
                            WHERE Id = :UserInfo.getUserId()];
            return UserObj;
            
        }catch(Exception e){
            System.debug('Exception ::' + e.getMessage() + '==============Line Number ::' + e.getLineNumber());
        }
        return null;
    }
    
    @AuraEnabled
    public static  List<SearchResultWrapper> getSearchResult(String searchKeyword){
        try{
            String searchkey = '%'+ searchKeyword + '%';
            System.debug('searchkey ::'+searchkey);
            List<Lead> leadList = new List<Lead>();
            List<Contact> contactList = new List<Contact>();
            List<SearchResultWrapper> searchResultWrapperList = new List<SearchResultWrapper>();
            leadList = [SELECT Name,Email FROM Lead WHERE Email != Null AND Name != Null AND (Name Like :searchkey OR Email Like :searchkey) LIMIT 50000];
            System.debug('leadList ::'+leadList);
            contactList =[SELECT Name,Email FROM Contact WHERE Email != Null AND Name != Null AND (Name Like :searchkey OR Email Like :searchkey )LIMIT 4];
            System.debug('contactList ::'+contactList);
            if(leadList.size()>0 || contactList.size()>0){
                for(Lead Obj : leadList){
                    SearchResultWrapper searchResultWrapperObj = new SearchResultWrapper();
                    searchResultWrapperObj.Name = Obj.Name;
                    searchResultWrapperObj.Email = Obj.Email;
                    searchResultWrapperObj.ObjectName = 'Lead';
                    searchResultWrapperList.add(searchResultWrapperObj);
                }
                for(Contact Obj : contactList){
                    SearchResultWrapper searchResultWrapperObj = new SearchResultWrapper();
                    searchResultWrapperObj.Name = Obj.Name;
                    searchResultWrapperObj.Email = Obj.Email;
                    searchResultWrapperObj.ObjectName = 'Contact';
                    searchResultWrapperList.add(searchResultWrapperObj);
                }
                System.debug('searchResultWrapperList'+searchResultWrapperList);
            }
            return searchResultWrapperList;
            
            
        }catch(Exception e){
            System.debug('Exception ::' + e.getMessage() + '-----Line Number::' + e.getLineNumber());
        }
        return null;
    }
    
    @AuraEnabled
    public static String senMail_apex(String sendFrom, List<String> To, List<String> Cc, List<String> Bcc, String Subject, String Body, List<String> Attachments){
        try{
            List<ContentVersion> contentVersionList = new List<ContentVersion>();
            List<Messaging.EmailFileAttachment> attachmentList = new List<Messaging.EmailFileAttachment>();
            System.debug('sendFrom :' + sendFrom);
            Set<Id> documentId = new Set<Id>();
            if(Attachments.size()>0){
                for(String obj :Attachments){
                    documentId.add(obj);
                }  
            }
            if(documentId.size()>0){
                contentVersionList = [SELECT VersionData,Title,FileExtension FROM ContentVersion WHERE ContentDocumentId In :documentId AND IsLatest = true] ; 
            }
            if(contentVersionList.size()>0){
                for(ContentVersion fileobj : contentVersionList){
                    Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
                    attach.filename = fileobj.Title + '.' + fileobj.FileExtension;
                    attach.body = fileobj.VersionData;
                    attachmentList.add(attach);
                }
            }
            
            
            
            Messaging.SingleEmailMessage sendMail = new Messaging.SingleEmailMessage();
            
            sendMail.setSenderDisplayName(sendFrom);
            sendMail.setToAddresses(To); 
            sendMail.setBccAddresses(Bcc); 
            sendMail.setCcAddresses(Cc); 
            sendMail.setSubject(Subject); 
            sendMail.setHtmlBody(Body);
            sendMail.setFileAttachments(attachmentList);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {sendMail}) ; 
            
            return null;
        }catch(Exception e){
            System.debug('Exception ::' + e.getMessage() + '-----Line Number::' + e.getLineNumber());
        }
        return null;
        
    }
    
    @AuraEnabled
    public static  List<ContentDocument> getFiles(){
        try{
            List<ContentDocument>  contentDocumentList = [SELECT id,ContentSize,ContentModifiedDate,FileExtension,Title,FileType 
                                                          FROM ContentDocument
                                                          LIMIT 50000];
            return contentDocumentList;
            
        }catch(Exception e){
            System.debug('Exception ::' + e.getMessage() + '-----Line Number::' + e.getLineNumber());
        }
        return null;
        
    }
    
    @AuraEnabled
    public static  List<ContentDocument> searchFiles( String searchKeyword){
        try{
            String searchkey = '%'+ searchKeyword + '%';
            List<ContentDocument>  contentDocumentList = [SELECT id,ContentSize,ContentModifiedDate,FileExtension,Title,FileType 
                                                          FROM ContentDocument WHERE
                                                          Title LIKE :searchkey
                                                          LIMIT 50000];
            return contentDocumentList;
            
        }catch(Exception e){
            System.debug('Exception ::' + e.getMessage() + '-----Line Number::' + e.getLineNumber());
        }
        return null;
        
    }
    
    
    public class SearchResultWrapper {
        @AuraEnabled
        public String Name {get;set;}
        @AuraEnabled
        public String Email {get;set;}
        @AuraEnabled
        public String ObjectName {get;set;}
    }
}
First, I'm new to Salesforce and the API.  I'm trying to familiarize myself with the API and using it on C#.  I've been able to accomplish the basic tasks.

I have been able to get a list of quotes.  I have also accessed the details of a sepcific quote.  I need to access the line items for a specific quote.

Which API call do I make?

Hello,
I am new to salesforce and I would like to know how to create custom button to update record's field value on click.

Should I use lightning component + apex code or is it possible achieve it without code?

Example - what I am trying to achieve:
FieldName:  Times clicked
FieldValue = 0 + 1 time clicked // sObject_c.TimesClicked++

Hi,
On Lead Record, email field must contain the first word of Lead Company field after the character ‘@’.

Thanks,
I am new in Apex, please help me to write trigger that should check the length of the Description field; if the field is longer than 200 characters, you need to trim it to 197 characters and add a three-dot at the end of the line.
there is a custom object 'Amount' with number value field 'Amnt' which is related to account by lookup. There is a field on account- 'Amt' it should show the sum of amount if the sum of amount is greater then 100 then it should not allow to insert any child record for a perticular account and should give an error- 'you have reached a maximum limit'

Hi there,
We have created a custom Lightning component that is called by an Action in Lightning. The component performs some pretty basic operations: it just updates a few fields on the record.

For users with the System Administrator profile, the feature works as intended. However, when other users use the feature, it takes about 20 seconds to execute, so the page refreshes for the user before the operation is complete (so the user thinks nothing has happened). Once the user refreshes the page after 20 seconds, they can see that the record has been updated.

We have been testing to try to identify why the feature doesn't work for non-Sys Admins but haven't been able to find anything. We tried giving the Profile modify all access to object + access to all fields, but that does not fix the issue. We have looked at other discrepancies between the Sys Admin and the other profile, but we haven't found anything that resolves it.

One other point: we have created a Javascript button for Classic that calls the underlying Apex Class directly, and this works fine for all users. We need to figure out a solutioln that will also work in Lightning.

 

Does anyone have thoughts on what could be causing this? or any potential fixes or workarounds? 

 

Thank you!

Brian

How to Create a formula field on Opportunity to show the percentage difference between Amount vs Expected Revenue.
Hi
I need to Change the Opportunity Stage to “Prospecting” whenever Opportunity Amount is changes to any value.

Thanks,
Aj
Hi Team,

Need a formula on Opportunity to show number of days since Opportunity is opened. 
For Ex: If Opportunity is created on 1st July, formula field will show “10 days” as of 10th July.
Use Created Date field. Do not show any date if Opportunity is “Closed Won” or “Closed Lost”.
In that case it would show “-1 day”.
Can someone tell me how to change the sizes of input fields in my lightning component, I am using layout and layout item to get them centered on the screen, but I would like both columns to look more uniform.  Also how would I get fields like Description to show more than one line like it does in the OOB Account creation screen? 

Here is the code I have so thus far:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="PageHeading" type="String" default="New Property Space"/>
    <aura:attribute name="PropertySpaceName" type="String"/>
    <aura:attribute name="SpaceStatus" type="String[]" default="--None--,Vacant, Occupied, Pending"/>
    <aura:attribute name="Property" type="String"/>
    <aura:attribute name="SquareFootage" type="Integer"/>
    <aura:attribute name="DesiredTenantNotes" type="Integer"/>
    <aura:attribute name="PreviousIndustry" type="String[]" default="--None--, TBD"/>
    <aura:attribute name="Tenant" type="String"/>
    <aura:attribute name="LeaseEffectiveDate" type="Date"/>
    <aura:attribute name="LeaseOpportunity" type="String"/>
    <aura:attribute name="LeaseExpirationDate" type="Date"/>
    <aura:attribute name="PropForm" type="PropertySpace__c" default="{'sobjectType': 'PropertySpace__c'}" />
    
    <div class="slds-m-top--xx-large">
    <div class="slds-page-header">
    <div class="slds-align--absolute-center">
    <div class="slds-text-heading--large">{!v.PageHeading}</div>
        </div>
    </div>
    </div>
    
    <br/>
    <div class="slds-text-heading--medium">Information</div>
    
    <div class="c-container">
        
    <lightning:layout verticalAlign="center" class="large">
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:input label="Property Space Name" name="PropertySpaceName" value="{!v.PropForm.Name}" />       
        </lightning:layoutItem>
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:select label="Space Status" name="SpaceStatus" value="{!v.PropForm.SpaceStatus__c}">
                <aura:iteration items="{!v.SpaceStatus}" var="sstat">
                    <option value="{!sstat}" text="{!sstat}" />
                </aura:iteration>            
            </lightning:select>       
        </lightning:layoutItem>
    </lightning:layout>    
    
    <lightning:layout verticalAlign="center" class="large">
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:input label="Property" name="Property" value="{!v.PropForm.Property__c}" />       
        </lightning:layoutItem>
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:input label="Square Footage" name="SquareFootage" value="{!v.PropForm.SquareFootage__c}" />      
        </lightning:layoutItem>
    </lightning:layout>      
        
    <lightning:layout verticalAlign="center" class="large">
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:input label="Desired Tenant Notes" name="DesiredTenantNotes" value="{!v.PropForm.DesiredTenantNotes__c }" />       
        </lightning:layoutItem>
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:select label="Previous Industry" name="PreviousIndustry" value="{!v.PropForm.PreviousIndustry__c }">
                <aura:iteration items="{!v.PreviousIndustry}" var="pind">
                    <option value="{!pind}" text="{!pind}" />
                </aura:iteration>            
            </lightning:select>       
        </lightning:layoutItem>
    </lightning:layout>
        
    <div class="slds-text-heading--medium">Current Tenant</div> 
        
    <lightning:layout verticalAlign="center" class="large">
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:input label="Tenant" name="Tenant" value="{!v.PropForm.Tenant__c}" />       
        </lightning:layoutItem>
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <ui:inputDate aura:id="LeaseEffectiveDate" label="Lease Effective Date" class="field" value="{!v.PropForm.LeaseEffectiveDate__c}" displayDatePicker="true" />      
        </lightning:layoutItem>
    </lightning:layout>
        
    <lightning:layout verticalAlign="center" class="large">
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <lightning:input label="Lease Opportunity" name="LeaseOpportunity" value="{!v.PropForm.LeaseOpportunity__c }" />       
        </lightning:layoutItem>
        <lightning:layoutItem flexibility="auto" padding="around-small">
            <ui:inputDate aura:id="LeaseExpirationDate" label="Lease Expiration Date" class="field" value="{!v.PropForm.LeaseExpirationDate__c }" displayDatePicker="true" />      
        </lightning:layoutItem>
    </lightning:layout>    
        
    </div>    
    
</aura:component> 

Here is a screenshot of the non-uniformity I am talking about:

User-added image

Thank you in advance for any help provided!
Hello,

I am trying to deploy this apex trigger from sandbox to production but keep getting this error:

Your organization's code coverage is 74%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.

I'm wondering what would be the best way to increase the code coverage with my trigger below. This trigger is used with Dropbox. Any help would be so appreciated!
 
trigger Dropbox_Trigger_Vendor on Vendor__c (after update, after delete) {
    
        if(Trigger.isAfter && Trigger.isUpdate){
            Dropbox_for_SF.HandleRecordChange.OnRecordChange(Trigger.old, Trigger.new);
        }
    
        if(Trigger.isAfter && Trigger.isDelete){
            Dropbox_for_SF.HandleRecordChange.HandleMerge(Trigger.old);
        }
}

 
Hello All

Some line in apex class is not covering please help me.

User-added image



 
public class UpdateAccountManagerEmailAdderss {
        
        public Static void updateAccountMgrEmail(List<case> lstcase)
        {   
         List<String> lstOfDomain=new  List<String>();  
    
         list <Account> lstAccounts = [Select Id,Account_Manager_Email__c from Account WHERE Old_HD_Provider__c!='ConnectWise' AND Status__c='Live'];
          Map<String,String>mapAccount=new  Map<String,String>();
            
            for(account a:lstAccounts){              mapAccount.put(a.id,a.Account_Manager_Email__c); 
      		}
    Map<string,string> mapDomain=new Map<String,String>();
    for(Account ks:[Select id,institutional_EmailDomain__c from Account WHERE Old_HD_Provider__c!='ConnectWise' AND Status__c='Live' and institutional_EmailDomain__c!=null])
    {
        lstOfDomain.add(ks.institutional_EmailDomain__c);
        mapDomain.put(ks.institutional_EmailDomain__c, ks.id);                                                      
                                                                   
        }
       for(case cs:lstcase)
         {
        if(lstOfDomain.size()>0){   
            for(String s:lstOfDomain)
            {  
                if(cs.Description!=null && ( cs.Description).Contains(s))
                {  
                    cs.AccountId=mapDomain.get(s);  
                    cs.Account_Manager_Email__c=mapAccount.get(cs.AccountId);
                   // cs.Identified_Keyword__c=s;
                } 
                else {
                    if((cs.Description).Contains('Test1ymail'))
                    {
                     cs.Account_Manager_Email__c='Test1ymail';   
                    }
                    if((cs.Description).Contains('Test2ymail'))
                    {
                      cs.Account_Manager_Email__c='Test2ymail';  
                    }
                    if((cs.Description).Contains('Test3ymail'))
                    {
                     cs.Account_Manager_Email__c='Test3ymail';   
                    }

                }
               
                       }}}}

}


test class is 


@isTest
public class UpdateAccountManagerEmailAdderss_Test {
    @isTest
    public static void testAcctMgr()
    {
       Map<Id,String> mapAccount =new Map<Id,String>();
       Map<String,String> mapDomain=new Map<String,String>();
        List<string>lstOfDomain=new List<String>();
        Account acc =new Account();
       acc.name='BlackeBeltHelp Agents';
       // acc.Account_Manager_Email__c='test.test@test.com';
        acc.Institutional_EmailDomain__c='ben.edu';
       insert acc;
       mapAccount.put(acc.id,acc.Account_Manager_Email__c);
        mapDomain.put(acc.Institutional_EmailDomain__c,acc.id);
        lstOfDomain.add(acc.Institutional_EmailDomain__c);
       Contact con=new Contact();
       con.accountId=acc.id;
       con.firstName='test';
       Con.lastName='testcontact';
       Con.Email='Shiv@str.tst';
        insert con;
             
        Trigger_Control__c tc=new Trigger_Control__c();
        tc.name='test';
        tc.Enable_Update_Account_Mgr_Email_Trigger__c=true;
        insert tc;
        List<case>lstcase=new List<case>();
        Case cs=new Case();
       
        cs.accountId=acc.id;
        cs.contactId=con.id;
        cs.Account_Manager_Email__c=acc.Account_Manager_Email__c;
        cs.description='kdjksjkfjkjdfsjmk smjkm';
        lstcase.add(cs);
        insert lstcase;
        UpdateAccountManagerEmailAdderss.updateAccountMgrEmail(lstcase);
       
        
    }

}

 
I have written an Apex class and its Test class which restricts a user from deleting an Account record if he is not the Account owner, but the class currently has 75% code coverage. How do I increase it to 100%?

Apex Class:
public class AccountDeleteCheckClass {
//Declare function if account owner is not the deleting user
public static void AccountDeleteCheck(list<Account> AccountsList){
for(Account VarA : AccountsList){
if(VarA.OwnerId != UserInfo.getUserId()){
VarA.addError('Only owner can delete');
}
}
}
}

Test Class:
@isTest
class AccountDeleteCheckClassTest
{
static testmethod void Function()
{
//Insert & delete a record
Account VarA = new Account();
VarA.Name = 'ABC Corp';
insert VarA;

//Check deletion
try {
delete VarA;
}
catch(Exception e)
{
System.assert(e.getMessage().contains('Only owner can delete'));
}
}
}
We need to create a storage location for a userguide(in any format pdf,excel etc) in salesforce and for that we have to give read only permissions to all users and Editable access to admin and selected users.

We have tried these two ways but couldn't find exact solution:

1- We have tried it using by creating a Folder in documents and giving readable access to all users and to give editable access to admin or some selected users we have created a permission set in which under System Permissions we just ticked the Manage public Documents checkbox.So by this all the users which are assigned in the permission set are able to manage all the folders but we want to manage only a particular folder.

2- We have also tried using content libraries.In that we created a library and added the content file in it.Gave permissions of viewing,editing to particular users but in this we are not able to add Chatter Only users so this solutions got breaked,adding to it some more profiles are asked to generate a case to salesforce support to get Salesforce CRM Content User License by this license only they can view or edit content.

Solutions for this is highly appreciable.And if any one can suggest how to modify any of above two ways to get required solution this will be a great help. I have also posted this question on salesforce community and Stack Exchage.

Thanks
I need to adjust the row height of the datatable (https://developer.salesforce.com/docs/component-library/bundle/lightning:datatable/example)

The default behaviour is it takes up as much height needed to accommodate the content, I need a way to resize the row size.

Attaching the image for reference
User-added imagea
I am working in Lightning.

I have created a lightning component to launch a flow from a case. How do I pull the case ID into the flow? Once I get the case that the flow was launched from, i can get everything else I need through the flow.
I am new to all this so basic steps if possible.

My lightning component is writtem in HTML and CSS.

Any help will be greatly appreciated.

Best regards,
Steve
Hi All, 
Is it possible to dynamically render design attributes based on the value of another attribute?  The purpose of this is to show different values within Lightning App builder based on the Admin's selection. 

For instance, let's say I have 2 Boolean attributes within the design bundle.  By default, attribute #2 isn't visible.  When attribute #1 is true, attribute #2 becomes visible, and vice versa. Is this possible within the DESIGN BUNDLE?
 
  • August 22, 2019
  • Like
  • 0
I have a visualforce page (NCR View) embedded on an object layout (Non Conformance).  The visual force displays the relevant fields in detail view.  I made another VF page (NCR Edit) that shows the same fields in edit view.

I've created an "Edit" button on NCR View that is meant to redirect me to the NCR Edit page by calling the method OpenPage.  I will eventually create a save button on the NCR Edit that saves the info and brinds you back to NCR View.

When I click the edit button it redirects me to the new page but that page doesn't seem to really be associated to the fields in the object at all. Ideas?

My extension class: 
public PageReference OpenPage() {
        PageReference pr = new PageReference('/apex/Material_Nonconformity_Report');
        pr.setRedirect(true);
        return pr;
    }

Call to the method in NCR View:
<apex:commandButton value="Edit" action="{!OpenPage}"/>
Hi,

I want to create a save button on lightning component for my object Shipping Address which is child to parent Account.

There are 6 fields in shipping address, I want those fields to get saved and displayed on the lightning component 

I am tricked about how do i save it into database and get it displayed on my screen.

Can anyone help me on this please
 
I have the following Apex class and VF page.  Based on the selection of the tite, the corresponding role should display. I am using the actionSupport to pass the selected value onchange event, and assign the value to selectedTitle. But the selectedTitle is null everytime. Any ideas?

Apex class:
public class selectListController
{
    public String title { get; set; }
    public String role { get; set; }    
    public String selectedTitle { get; set; }        
    public List<selectOption> titleList { get; set; }
    public List<selectOption> roleList { get; set; }
    
    public selectListController()
    {
        titleList = new List<selectOption>();
        titleList.add(new SelectOption('', '--None--'));
        for (TitleRoleAssociation__c title : [Select Title_Definition__r.Name from TitleRoleAssociation__c]) {
            titleList.add(new selectOption(title.Title_Definition__r.Id, title.Title_Definition__r.Name));
        }
    }
    
    public PageReference getRoles(){
        roleList = new List<selectOption>();
        roleList.add(new SelectOption('', '--None--'));
        System.debug('Selected title: ' + selectedTitle);
        for (TitleRoleAssociation__c role : [Select Role_Definition__r.Name from TitleRoleAssociation__c where Title_Definition__r.Name = :selectedTitle]) {
            roleList.add(new selectOption(role.Role_Definition__r.Id, role.Role_Definition__r.Name));
        }
    
        return null;
    }
    
}

VF page:
<apex:page controller="selectListController">
    <apex:form>
        <apex:selectList value="{!title}" multiselect="false" size="1">
            <apex:selectOptions value="{!titleList}" />
            <apex:actionSupport event="onchange" action="{!getRoles}" reRender="role" status="status">                         
               <apex:param name="selectedTitle" value="{!title}" assignTo="{!selectedTitle}"/>
            </apex:actionSupport>            
        </apex:selectList>

        <apex:outputPanel id="role">
        <apex:selectList value="{!role}" multiselect="false" size="1">
            <apex:selectOptions value="{!roleList}" />
        </apex:selectList>        
        </apex:outputPanel>
    </apex:form>
</apex:page>
 
Has anyone successfully changed the color of a link in a Lightning Component based on some attribute on the Component?  I can change the link color all the time but not conditionally.
One of our Client is using professional edition. Our requirement is customization in the standard object which uses apex classes and triggers. We identified that Professional edition does not support Apex class and triggers and the client is not willing to upgrade it to Enterprise edition.

And if we purchase the RestAPI license can we deploy the Apex code in Professional Editon?

Also, we noted that the only way to deploy apex classes via managed packages. Is there any hack/Workarounds available? Quick responses are appreciated.

Thanks,
Nancy
Hi,

I need a recommendation of trailheads to be done to learn lightning development as a beginner. As I can see, there are a lot of trails to learn and it's confusing where to start from. So can anyone share the order in which I should solve them (from basics to advanced)

TIA
<aura:iteration items="{!v.QliList}" var="Qli" indexVar="sNo">      
               <tr>
                    <td><div class="slds-truncate">{!sNo+1}</div></td>
                    <td><div class="slds-truncate">{!Qli.Name}</div></td>
                    <td><div class="slds-truncate">{!Qli.Description__c}</div></td>
                   <td><div class="slds-truncate">{!Qli.Family__c}</div></td>
                   <td><div class="slds-truncate"><ui:inputText aura:id="dynamicResult" class="pnsuggestion" value="{!Qli.Part_number_Suggestion__c}"/></div></td>
                   <!--<td><div class="slds-truncate">{!Qli.PN_Suggestion__c}</div></td>-->
                    <td><div class="slds-truncate"></div>
                    <lightning:button type="button" onclick="{!c.UpdatePnsuggestion}"   name="CMM Tooling and Accessories" label="{!sNo}">CMM Tooling and Accessories</lightning:button>
 </td>
                </tr>
          </aura:iteration>

//JS

    UpdatePnsuggestion: function(component,event,helper){
       var va= event.getSource().get("v.name");
       var indexnumber= event.getSource().get("v.label");
      console.log(indexnumber);
        component.set("v.QliList.Part_number_Suggestion__c", va);  
    },  

I want to pass the button value to inputtext field {!Qli.Part_number_Suggestion__c}

In iteration n number of record when I click on a button it is copying the value to all records. But in my case, I would like to copy value only to the current row.
 
For example,
I am having 2 record types,
1. Production
2.Testing

I want to hide the standard field for "Testing" record type.
Hi, 

I would like to know if there is a way by which we can understand if an apex class is never called in recent times. In my org, the apex character limit has touched over 77%. I am sure that there are a lot of classes which are old and obsolete.  How can I identify them? Is there a tool for that? 
HTTP Rest post request to send data from salesforce to end point url (this end point url is other than Salesforce).
Can anyone please give a sample end point URL to test and Source code related to it?
Am a newbie to salesforce,Can anyone explain.

 
Hello all

i am new to the vf, i am trying to populate the field values in a table format for the custom object, (i have not used Custom controllers)
how do i populate the field values in 2 columns like shown in the snapshot




below is my code

<apex:page standardController="Apartment__c" showHeader="false" renderAs="pdf" DocType="html">
<apex:form >
   <apex:pageBlock title="Appartment Details">
           <apex:pageBlockSection >
         <table style="width:100%">   
         <tr> 
          <td> <apex:outputField value="{! Apartment__c.Name }" /> </td>
          <td> <apex:outputField value="{! Apartment__c.Floor_No__c }"/> </td>
          <td> <apex:outputField value="{! Apartment__c.Phase__c }" /> </td>
         <td> <apex:outputField value="{! Apartment__c.Property_No__c }"/> </td>
         <td> <apex:outputField value="{! Apartment__c.Facing__c }" /> </td>
          <td> <apex:outputField value="{! Apartment__c.Terrace_Area_Cost__c }"/> </td>
          </tr> 
    </table>
    </apex:pageBlockSection>     
</apex:pageBlock>
</apex:form>
</apex:page>

it should show something like this
Hi All,

I have developed an apex class whcih basically assign users to queue dynamically.I have a VF page which will launch from a custom VF tab.This VF page shows few users and with the checkbox.When checkbox against the username is marked and hit Save button then seleected users will go to the queue defined in class.
Below is my clas:
public class TodayTelesalesDetails {

public Date Today { 
    get { 
        return Date.today(); 
    }
}
public List<wrapAgent> wrapAgentList{get; set;}
public List<User> selectedAgents{get;set;}

public TodayTelesalesDetails (){
   
    if(wrapAgentList == null) {
        wrapAgentList = new List<wrapAgent>();

        for(User teleSalesAgent: [select Id, Name, Email from User where Name IN('Steve Waugh','Yuvraj Singh')]) {
            // As each agent is processed we create a new wrap object and add it to the wrapAgentList
            wrapAgentList.add(new wrapAgent(teleSalesAgent));
    }
}
}

public PageReference doFullSave(){

    set<id> userSetId = new set<id>();
    list<GroupMember> gmm = new list<GroupMember>();
    List<GroupMember> toBeDeleted= [SELECT Id, GroupId, UserOrGroupId FROM GroupMember where GroupId = '00G9D000000toPYUAY'];
    delete toBeDeleted;
    List<User> userlist=[select Id, Name from User where Name IN('Steve Waugh','Yuvraj Singh')];
   
    for(User u : userlist)
    { 
    system.debug('message3>>'+u);
         for(wrapAgent wrapAccountObj : wrapAgentList) {
             
            if(wrapAccountObj.selected == true) {
                userSetId.add(wrapAccountObj.teleAgent.id);
                
            }
        }

    }
      
    for(User us : [select id from User where id =: userSetId])
    {
       
        for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue'])
        {
            GroupMember gm = new GroupMember();
            gm.groupId = gg.id;
            gm.UserOrGroupId = us.Id;
            gmm.add(gm);
        }
        
    }
            
     
    insert gmm;
    PageReference pageRef = new PageReference('/');
            pageRef.setRedirect(true);
            return pageRef;
    }
   
   
    
 public PageReference doCancel(){
         
         PageReference pageRef = new PageReference('/');
            pageRef.setRedirect(true);
            return pageRef;
    }


 public class wrapAgent{
    public User teleAgent {get; set;}//Please put the custom metadata names
    public Boolean selected {get; set;}


    //This is the contructor method. When we create a new object we pass a telesales metadata member that is set to the acc property. We also set the selected value to false
    public wrapAgent(User teleSalesAgent) {
        teleAgent = teleSalesAgent;
        selected = false;

    }
}
}
and below is my test class:
@isTest
public class Test_TodayTeleSalesDetails {

    public static testMethod void validateusersinqueue() {
    Group testGroup = new Group(Name='test group', Type='Queue');
	insert testGroup;

	System.runAs(new User(Id=UserInfo.getUserId()))
	{
    QueuesObject testQueue = new QueueSObject(QueueID = testGroup.id, SObjectType = 'Lead');
    insert testQueue;
	}
   	Test.startTest();
     TodayTelesalesDetails telesalesDetails=new TodayTelesalesDetails();
       telesalesDetails.doFullSave();
        telesalesDetails.doCancel();
    Test.stopTest();
}
}

I am not able to cover below lines of code:
for(User us : [select id from User where id =: userSetId])
    {
        system.debug('message6>>'+us);
        for(Group gg : [select id,name from Group where type = 'Queue' and Name = 'TeleSales Queue'])
        {
            GroupMember gm = new GroupMember();
            gm.groupId = gg.id;
            gm.UserOrGroupId = us.Id;
            gmm.add(gm);
        }
        
    }
Below is the screenshot for the same:
Lines of Code is not covering
My current code coverage stands at 73%

Many I request to help me on same to get a code coverage above 75%

Many thanks in advance

Thanks & Regards,
Harjeet
Hi all,
I have created a batch class but still i am getting error "First error: Too many Email Invocations: 11" .

Can anyone solve this issue.
Below is my batch class.
global class batchexpense implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
       String query = 'Select Name_of_Employee__c from Expense_Management__c where CreatedDate = LAST_N_DAYS:15';
       return Database.getQueryLocator(query);
     }
    
	global void execute(Database.BatchableContext BC, List<Expense_Management__c> scope){
   		Set<String> myset = new Set<String>();
		for(Expense_Management__c aa : scope)
		{
  			myset.add(aa.Name_of_Employee__c);  
		}    
				
		
   		 for(Expense_Management__c cc : [select id,Name_of_Employee__r.email,Name_of_Employee__c from Expense_Management__c WHERE Name_of_Employee__c =: myset ])
        {
         
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
			Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.ExpenseReport;
            pref.getParameters().put('Id',cc.Name_of_Employee__c );
            pref.setRedirect(true);
             Blob b;
             if(Test.isRunningTest()) { 
                b = blob.valueOf('Unit.Test');
            } else {
                b = pref.getContent();
            }
            attach.setFileName('Expense.pdf');
            attach.setBody(b);
            semail.setSubject('Expense details');
            semail.setSaveAsActivity(true);
         
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
            semail.setWhatId(cc.Id);
     
            
            List<String> sendTo = new List<String>();//to string
           	sendTo.add(cc.Name_of_Employee__r.email);
            semail.setToAddresses(sendTo);
           
            mails.add(semail);
            String emailBody =' <html><body><p> Dear  ,<br><br> Please find the attached Expense details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
     }
    
    	global void finish(Database.BatchableContext BC){
        
    	}
}

Thanks in advance
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Fulfillment Creation” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: Assigned To ID: id value of incorrect type: 0063i000003ZVyyAAG. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 990470032-165661 (-1137041356): []
I'd like to describe this case in detail: First , we have created an custom sObject which OWD is Private Second, we have an approval process on this sObject and user created an record and submit for approval Third, his manager reassigned user's request to another person who has no right to view user's record because OWD is private and also has no role hierarchy with this user My question is : Can we add custom logic when manager reassign this approval to another person? So that we can apex sharing this record to person.

Appreciate for any help
HI, anyone take Platform developer certification in 2019?. can you please provide reference links and simple quiz if its available online
Hi Expert,

I am new to the programming world. I have a custom controller which insert a contact created on VF page. Now I am not able to write test class for this. I could only cover 56% code.
 
public class TestPopup {
    
    public list<Account> acc{get;set;} 
    public Account acc1 {get;set;} 
    public Contact contact {get;set;}
    public List<Contact> conlist;
    public Boolean displayPopup {get;set;}
    public String accid {get;set;}
       

    public TestPopup(){
        acc = [select ID, Name, AccountNumber,Type from Account];
	    acc1 = new Account();
        conlist = new List<Contact>();
        contact = new Contact();
        	
    }
   
    public list<Account> getacc(){
        return acc;
    }
    
    public void showPopup()
    { 
    	displayPopup = true;
        acc1 = [SELECT Id, Name, Phone, (SELECT lastName FROM Contacts) FROM Account WHERE Id = :accid];
    }
       
    public void closePopup() {
        displayPopup = false;
        
    }

    public PageReference save(){
        contact.AccountId= acc1.Id;
        insert contact;
        ID contactId = contact.Id;
        PageReference pr = new PageReference('/' + contactId);
   		return pr;
    }  
        
}
 
@isTest
public class TestCustomController {
     static testMethod void testMethod1() 
     {
         Account testAccount = new Account();
         testAccount.Name='Test Account';
         insert testAccount;
         
         Contact cont = new Contact();
         cont.LastName = 'Test';
         cont.FirstName = 'Contact';
         cont.AccountId = testAccount.Id;
          // insert cont;
         
         Account testAccount1 = new Account();
         testAccount1 = [SELECT Id, Name, Phone, (SELECT lastName FROM Contacts) FROM Account WHERE Id = :testAccount.Id];
       
         
         
         Test.StartTest(); 
         PageReference pageRef = Page.All_Account; // Add your VF page Name here
         pageRef.getParameters().put('id', String.valueOf(testAccount.Id));
         Test.setCurrentPage(pageRef);
         
         TestPopup testAccPlan = new TestPopup();  
         testAccPlan.getacc();
        // testAccPlan.showPopup(); 
         testAccPlan.closePopup();
         
         Test.StopTest();
         
     } 
}

 
Hi,

Cannot save the Controller, please help.

https://trailhead.salesforce.com/projects/quickstart-lightning-components/steps/quickstart-lightning-components4
Ok, been directed here by support so hoping someone can help.

Basically noticed that our case milestones were violating outside our set business hours.  After a lot of head scratching the only conclusion was that our timezone on the business hours in use by the entitlement processes were set to GMT.  I have changed this to BST (British Summer Time) to prevent more out of hours violations.

I have asked support if having it set to BST would mean that come Autumn salesforce will automatically revert back an hour in line with daylight savings.  They have said this does not occur and you have to manually change the timezone each time daylight savings occurs.

Can anyone confirm if this is true?  Seems like something so basic that I can't believe its not in the system. 
  • April 21, 2016
  • Like
  • 3

Hi, 

This Monday I tried to do the exam but I had technical issues with camera. Kryterion support tried to help me but we couldn't solve the problem. They rescheduled my exam multiple times but they can not do it to a different day.

Please, I have opened cases and called to certification support phone without getting any answer. Could you help me?

Best regards
I want to send emails in user's language dynamically. Two approaches:
1. Use visualforce email template, create labels and use them in the template. Set language attribute in the template and provide translations for the labels using translation workbench.
2. Create multiple versions of each template, each in a separate language and choose the template dynamically.

Advantage of first approach is that no additional efforts are required if a new language is to be supported but creating so many custom labels is cumbersome. 2nd approach is good in that respect but a template needs to be added everytime a new language is supported. 
Is there any other approach? If not, which one of the above should be chosen?