• Bavadharani Ganesan
  • NEWBIE
  • 55 Points
  • Member since 2019

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 15
    Replies
Hi,

I'd like to use the User Rolename from the logged in user in a validationrule on an Opportunity but I can't get it to work. I made a formula text field to show $UserRole.Name to see the result but it is empty or not showing. Tried $UserRole.RollupDescription. Also empty or not showing.

UserRole.Name

I quess that is why my validationrule is not working.

I can't find any topic on it but it seems like none of the UserRole fields has any result or it is not showing when I open an Opportunity.

What did I do wrong?

regards,
Marco
Hi,
In the below code, how shall I get the 'MailingCity' of contact from the relatedContactMap.


Map<Id,List<Contact>> relatedContactMap = new map<Id,List<Contact>>();
List<Contact> relatedContactList = new List<Contact>();

for(Contact con: [SELECT Id,AccountId, MailingCity, MailingStreet, MailingState,
                  MailingPostalCode, MailingCountry FROM Contact WHERE 
                  AccountId ='0015Y00002m8cuE' AND ID != '0035Y00003wkUi4'])
//Here the accountId is same for all 13 contacts. so we have check containskey. otherwise only one contact will be added to this map since the key should be unique.
{
    if(!relatedContactMap.containskey(con.AccountId))
    {
        relatedContactMap.put(con.AccountId, new List<contact>{con});
    }
    else
    {
        relatedContactList = relatedContactMap.get(con.AccountId);
        relatedContactList.add(con);
        relatedContactMap.put(con.AccountId,relatedContactList);
    }
}
system.debug('relatedContactMap '+relatedContactList.size());

for(contact con : [SELECT Id,AccountId, MailingCity, MailingStreet, MailingState,
                  MailingPostalCode, MailingCountry FROM Contact WHERE 
                   ID = '0035Y00003wkUi4'])
{
  system.debug('relatedContactMap.get(con.AccountId) '+relatedContactMap.get(con.AccountId).???);
}
 
Hi All,

We have a parent child relationship on the Case object. Basically a self look up relationship. 

We would like to know the number of child cases a parent case has and store in a field called "No of child Cases"

Any suggestions to get this requirement accomplished ?

Thanks
Natraj
Hi, 

I am getting the below exception.

This page has an error. You might just need to refresh it. Unable to find action 'doInit' on the controller of c:contactRecordDispaly Failing descriptor: {c:contactRecordDispaly}

<aura:component controller="contactRecordData" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="conts" type="Contact[]" />    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <table>
        <th>
            <div title="Name">Contact Name</div>
        </th>
        <th>
            <div title="Id">Contact Id</div>
        </th>
        <th>
            <div title="Phone">Phone</div>
        </th>
        <th>
            <div title="Email">Email</div>
        </th>
        <aura:iteration items="{!v.conts}" var="cnt" >
            <tr>
               <div>{!cnt.name}</div>
                <div>{!cnt.Id} </div>
                <div>{!cnt.Phone}</div>
                <div>{!cnt.Email}</div>
            </tr>
        </aura:iteration>
    </table>
</aura:component>

public class contactRecordData {
    @AuraEnabled
    public List<Contact> getContactList(){        
        List<Contact> conList=[select id,FirstName,LastName,Email,Phone    from Contact];
    return conList;
    }

}

({
    doInit : function(component, event, helper) {
        var action = component.get("c.getContactList");
        action.setCallback(this, function(response)
        {
            var state=response.getState()
        if(state==="SUCCESS")
        {
            var Results=response.getReturnValue();
            component.set("v.conts",Results);
        }
                           });
         $A.enqueueAction(action);
    }
        
    
})
Hello,

I am getting below error.

Error:
System.NullPointerException: Attempt to de-reference a null object

Class.BMCRF_GetAssetDetails.assetDetails: line 52, column 1
Class.BMCRF_GetAssetDetails_Test.setupTestData: line 43, column 


@isTest 
public class BMCRF_GetAssetDetails_Test
{  
            // insert base element data    
                @isTest
                static void setupTestData() 
                {  
                    Profile profile1 = [Select Id from Profile where name = 'System Administrator'];
                    System.debug('What is the profile id---------------------------------> ' + profile1);
                    UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1];
                    System.debug('portalRole--------------------------------->  ' + portalRole);
                    date tDate = date.today();
                    date uDate = Date.today().addDays(30);
                    User us2 = new User(
                    UserRoleId = portalRole.Id,
                    ProfileId = profile1.Id,
                    Username = 'test@networks.com',
                    Alias = 'sal',
                    Email='test@networks.com',
                    EmailEncodingKey='UTF-8',
                    Firstname='test',
                    Lastname='testDemo',
                    LanguageLocaleKey='en_US',
                    LocaleSidKey='en_US',
                    TimeZoneSidKey='Asia/Singapore',BMCServiceDesk__Account_Name__c='test');
                    insert us2;
                    
                     System.runAs(us2)
                     {
                         List<BMCServiceDesk__BMC_BaseElement__c> bas=new List<BMCServiceDesk__BMC_BaseElement__c>();
                         BMCServiceDesk__BMC_BaseElement__c baseElement= new BMCServiceDesk__BMC_BaseElement__c();   
                         baseElement.BMCServiceDesk__Name__c= 'Test Company';
                         baseElement.BMCServiceDesk__PrimaryClient__c=us2.id;
                         baseElement.BMCRF_ResourceId__c='34784';
                         baseElement.BMCServiceDesk__CMDB_Class__c= 'a2Z1X000000RXZaUAO';
                         
                         insert baseElement;
              
                     }  
                           
                         Test.startTest();
                         BMCRF_GetAssetDetails s=new BMCRF_GetAssetDetails();
                         s.assetDetails();
                         Test.StopTest();
                                          
                   
                   } 
 }
Hi,

I'd like to use the User Rolename from the logged in user in a validationrule on an Opportunity but I can't get it to work. I made a formula text field to show $UserRole.Name to see the result but it is empty or not showing. Tried $UserRole.RollupDescription. Also empty or not showing.

UserRole.Name

I quess that is why my validationrule is not working.

I can't find any topic on it but it seems like none of the UserRole fields has any result or it is not showing when I open an Opportunity.

What did I do wrong?

regards,
Marco
Can we do calculations based on one or multiple fields while doing reporting without creating formula field in the object?
Hi Team,

I recently moved to a new project where I've been asked to analyze existing code. I see code similar to below,
public class Zinc_AccountDetail {
    @auraenabled public Id Id {get; set;}
    @auraenabled public String Organizationname{get; set;}

}

How to find which apex/visual force/aura component is using Zinc_AccountDetail ?

 
how to save opp approval and rejection comments in Opp related list.
  • June 12, 2019
  • Like
  • 0
I pushed an Apex Class and Trigger to production but my TestClass is in sandbox, when the tests are run in production before deployment, does it run all tests from production, sandbox or both?
Not sure what is going on here, tried maually updating all of the fields, yet get a generaic "Default Settings not defined", when running an insert. Does anyone know if this is an issue or a way of getting a more detailed Exception error?

private static fw1__Invoice__c anInvoiceFor(Decimal amount, Account account, Contact contact){
fw1__Invoice__c invoice = new fw1__Invoice__c(
fw1__Account__c = account.Id,
fw1__Contact__c = contact.Id,
fw1__Invoice_Date__c = Date.today(),
fw1__Terms__c = 10,
fw1__Description__c = 'An invoice',
fw1__Due_Date__c = Date.today(),
fw1__Is_Voided__c = false
);
insert invoice;
Picklist field- Type_Of_Bedroom__c
its values are 1bhk(30 unit),2bhk (30 unit),3bhk (20 unit)
if a user select 1bhk and if he saves the record, the picklist value should be changed as 1bhk(29 unit) is that possible ?