• Sandeep Walia
  • SMARTIE
  • 574 Points
  • Member since 2016
  • Salesforce Developer

  • Chatter
    Feed
  • 15
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 57
    Replies
Hello,

I have requirment to crate field as from vf by selecting data type.
If I selected data type from picklist as text data type  and input value Enter Name for that field this field display as input field(Enter Name With text box) on another page or same page.

PFA
  


User-added image
We are loading the Case from the website. There is an issue with Images field in Case entity as displayed below:

Text in Images Field in Case entity : ["https:\/\/www.intops.com.au\/wp-content\/uploads\/gravity_forms\/2-cb870933d1056667864f32a0efe9bcff\/2018\/08\/MDC3521112.JPG";]
 
So, everytime we have to remove the junk characters and set it as below and check the images.
 
Need update: https:\\www.intops.com.au/wp-content/uploads/gravity_forms/2-cb870933d1056667864f32a0efe9bcff/2018/08/MDC3521112.JPG

Can you please help to write a trigger to truncate the junk characters. Thanks a lot 

 
Hi,
from image..once table extends to 2nd page , the last border is breaking..Please help me to manage this table wthout breaking border line..
please check my attachment .
User-added image
Hello, This question is already asked, But my question is something different.

According to me, the above error occurs when the user is idle for some time (i,e standard expiry time of session) and tried to save an opportunity or anything in Salesforce.

So I would like to know is this error solves when user refresh the page?

And also what is the duration of the session?

Any help will be really appreciated.
 
I have an apex trigger which does not align (AT ALL!) with Salesforce "Best Practice" of never having queries and/or DMLs inside a 'for' loop.

I know this theory but, as I am new to coding, I need to break the ice and put this theory into practice (for the first time of my life) and I would like to ask if there is a "Best approach" to doing precisely that (moving SOQL-queries and/or DMLs outside the 'for' loop on 'Trigger.new', or for that matter, to move them from any loop).

Is there any approach, guide, video that could teach me to learn this "optimization process" of my code?

Below, here is my trigger (but please, do not give me the whole solution yet/inmediately, I am looking for a guide for me to try putting it into practice); thank you!:

==>This trigger adds Team Members to an Opportunity upon creation of that new Opportunity:
trigger OwnerManager on Opportunity (after insert) {
    for(Opportunity opp : Trigger.new){
        //Get opp Owner.Manager info
        Opportunity oppWithManagerInfo = [SELECT Id,
                                          Owner.ManagerId
                                          FROM Opportunity
                                          WHERE Id = :opp.Id];
        //Get opp Owner direct dependents
        List<user> directDependents = [SELECT Id
                                       FROM user
                                       WHERE ManagerId = :opp.OwnerId
                                       LIMIT 1];
        //Create Opportunity Team Role
        if (oppWithManagerInfo.Owner.ManagerId != null) {
            OpportunityTeamMember otm = new OpportunityTeamMember();
            otm.UserId                = oppWithManagerInfo.Owner.ManagerId;
            otm.OpportunityId         = opp.Id;
            otm.TeamMemberRole        = 'Sales Manager';
            insert otm;
            //Create another Opportunity Team Role with directDependent
            if (directDependents.size()>0){
                OpportunityTeamMember otm2 = new OpportunityTeamMember();
                otm2.UserId                = directDependents[0].Id;
                otm2.OpportunityId         = opp.Id;
                otm2.TeamMemberRole        = 'Sales Rep.';
                insert otm2;
            }
        }
    }
}

 
Hello all,

In the Create & Edit Visualforce Pages challenge, for #6 in the first part they ask you to run a command in Console to make the page look like Lightning. When I run this command, I am receiving the error "Uncaught ReferenceError: $A is not defined at <anonymous>:1:1".

Has the command changed?

Thank you!
Hi
I have been trying to pass this challenge (https://trailhead.salesforce.com/en/trails/force_com_dev_intermediate/modules/apex_integration_services/units/apex_integration_webservices):

To pass this challenge, create an Apex REST class that is accessible at '/Accounts/<Account_ID>/contacts'. The service will return the account's ID and Name plus the ID and Name of all contacts associated with the account. Write unit tests that achieve 100% code coverage for the class and run your Apex tests.
The Apex class must be called 'AccountManager'.
The Apex class must have a method called 'getAccount' that is annotated with @HttpGet
The method must return the ID and Name for the requested record and all associated contacts with their ID and Name.
The unit tests must be in a separate Apex class called 'AccountManagerTest'.
The unit tests must cover all lines of code included in the AccountManager class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.

I getting this error:

Challenge Not yet complete... here's what's wrong: 
Executing the 'AccountManager' method failed. Either the service isn't configured with the correct urlMapping, is not global, does not have the proper method name or does not return the requested account and all of its contacts.

This is my code:
 
@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager {
	
    @HttpGet
    global static List<sObject> getAccount(){
        RestRequest request = RestContext.request;
        List<String> urlParams = request.requestURI.split('/');
        
        String accountId;	
        for(String param: urlParams){
            if((param != 'Accounts') && (param != 'contacts'))
                accountId = param;
        }
    
        List<Account> lstAccounts = new List<Account>();
        lstAccounts = [SELECT Id, Name FROM Account WHERE Id = :accountId];
        
        List<sObject> result = new List<sObject>();
        result.add(lstAccounts[0]);
        
        List<Contact> lstContacts = [SELECT Id, Name FROM Contact WHERE AccountId = :accountId];
        for(Contact c:lstContacts){
            result.add(c);
        }
        return result;
    }
}

This is my response
 
[ {
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v39.0/sobjects/Account/001o0000015hgVBAAY"
  },
  "Id" : "001o0000015hgVBAAY",
  "Name" : "SFDC Computing"
}, {
  "attributes" : {
    "type" : "Contact",
    "url" : "/services/data/v39.0/sobjects/Contact/003o000001DbYc8AAF"
  },
  "Id" : "003o000001DbYc8AAF",
  "Name" : "Pepito Peres"
}, {
  "attributes" : {
    "type" : "Contact",
    "url" : "/services/data/v39.0/sobjects/Contact/003o000001BsUPwAAN"
  },
  "Id" : "003o000001BsUPwAAN",
  "Name" : "Last0"
} ]

Can someone light my way?​
i have one wrapper class in tha class two data members account and list contacts.
and i have list of wrapper class.i want to show list of wrapper in vf page.But it showing error .How to solve this Pls anyone help me.
How To Split String by space and store each character or substring in array
I have: String  -   '(1 OR 2) AND 3'
I need in this way: 

String [] filterLogicSplittedbySpace=new String[]{'(', '1', 'OR', '2', ')', 'AND', '3'};

Please guide.
 

trigger cc_contactUpdateOnApplication on Application__c (after update) {
    Map<id,id> applicationMap = new Map<id,id>();
    List<contact>conList = new List<contact>();
    for(Application__c application : [SELECT id,Name,Contact__c,CC_Term__c,Admissions_Status__c FROM Application__c Order By LastModifiedDate DESC Limit 1]){
        system.debug('@@@@@application'+application);
        if(application.Admissions_Status__c != Trigger.oldMap.get(application.Id).Admissions_Status__c){
            // if(application.Admissions_Status__c !=null){
            applicationMap.put(application.Contact__c, application.Id);
            system.debug('#####applicationMap'+applicationMap);
        }
    } 
    for(contact con :[SELECT id,Name,Active_Application_CC__c FROM contact WHERE Id IN :applicationMap.keySet()] ){
        con.Active_Application_CC__c = applicationMap.get(con.Id);
        conList.add(con);
        system.debug('$$$$conList'+conList);
    }
    if(conList.size() >0){
        update conList;
        system.debug('####conList'+conList);
    }
}
Hello all! 

I have a trigger which operates just fine for all scenarios (Insert, Update, Delet and undelete) but when i am attempting to create a test class for the trigger to test my first scenario I am getting a null pointer exception with the folllowing error: 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AcctSubMrrRollup: execution of AfterInsert

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

Trigger.AcctSubMrrRollup: line 18, column 1: []

Please see my Trigger and test class below, can anyone advise what i may e doing incorrect as in theory my trigger should be doing things correctly and I am not sure why my Map is Null even after fulfillign the If statement criteria on not being null?

Please help...

Thanks for your time,

​Shawn

Trigger Code: 
trigger AcctSubMrrRollup on Zuora__SubscriptionProductCharge__c(after insert, after update, before delete, after unDelete) {
    List<Id> AccIds=new List<Id>();
    
If(Trigger.isInsert || Trigger.isUpdate || Trigger.isUnDelete) {
    for(Zuora__SubscriptionProductCharge__c mst:Trigger.New){
    if(mst.Zuora__Account__c !=null){
     AccIds.add(mst.Zuora__Account__c);
    }
    }
   

   Map<Id,Account> AccMap = new Map<Id,Account>([select id,Subscription_MRR__c from Account where id in:AccIds]);
   
   for(Zuora__SubscriptionProductCharge__c mst:Trigger.New)
   {
        if(!AccMap.IsEmpty())
        {
            AccMap.get(mst.Zuora__Account__c).Subscription_MRR__c = AccMap.get(mst.Zuora__Account__c).Subscription_MRR__c + mst.Zuora__MonthlyRecurringRevenue__c;
        }
   }

   if(!AccMap.IsEmpty())
   {
        update AccMap.values();
   }}
   
   If(Trigger.isDelete) {
    for(Zuora__SubscriptionProductCharge__c mst:Trigger.Old){
    if(mst.Zuora__Account__c !=null){
     AccIds.add(mst.Zuora__Account__c);
    }
    }
   

   Map<Id,Account> AccMap = new Map<Id,Account>([select id,Subscription_MRR__c from Account where id in:AccIds]);
   
   for(Zuora__SubscriptionProductCharge__c mst:Trigger.Old)
   {
        if(!AccMap.IsEmpty())
        {
            AccMap.get(mst.Zuora__Account__c).Subscription_MRR__c = AccMap.get(mst.Zuora__Account__c).Subscription_MRR__c - mst.Zuora__MonthlyRecurringRevenue__c;
        }
   }

   if(!AccMap.IsEmpty())
   {
        update AccMap.values();
   }}

}

Test Class Code:
@isTest
public class AcctSubMrrRollupTest {

    public static testMethod void tm1 (){
        
     Account a = new Account();
        a.Name = 'Test Account Rollup';
        
        insert a;
        
        System.debug('The Id for the newly created Account is ' + a.Id);
        
     Zuora__SubscriptionProductCharge__c z1 = new Zuora__SubscriptionProductCharge__c();
        z1.Name = 'Testing 1';
        z1.Zuora__Zuora_Id__c = '12345';
        z1.Zuora__MonthlyRecurringRevenue__c = 100;
        z1.Zuora__Account__c = a.Id;
        
        insert z1;
        
        System.debug('The ID for the newly created Sub Record is ' + z1.Id);
        
        System.assertEquals(100, a.Subscription_MRR__c);
        
    }
    
}

 
When I say debug log I am referring to the following screenshot:





User-added image
where can I find a resource that will teach me how to read this info.

Many Thanks.
Charlene.
{ "destination_addresses" : [ "Bengaluru, Karnataka, India" ], "origin_addresses" : [ "Hyderabad, Telangana, India" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "576 km", "value" : 575574 }, "duration" : { "text" : "8 hours 33 mins", "value" : 30763 }, "status" : "OK" } ] } ], "status" : "OK" }


Thanks
 
My inputTextarea with richText enabled isn't firing events. However, if the richText is disabled the event works.
 
<apex:inputTextarea onchange="change()" richText="true" value="{!content}"/>

<script>
                function change() {
                    console.log('changed');
                }
</script>

How can I solve this?
I have a Javascript button in Lightning that needs to go out to SpringCM and pulls a form up that our users complete, it uses fields from the Opportunity that it pass through the URL. I am desperately trying to figure out how to do this and have tried the Trailhead Module: Lightning Alternatives to JavaScript Buttons and either it does not explain for my example or I am unable to understand. Can someone point me to any other solutions?

The Button is below:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} 

//Should not have to change this at all 
function getEOSInfo(objectid,objecttype,callback) { 

var baseUrl = "{!$Api.Partner_Server_URL_260}".substring(0, "{!$Api.Partner_Server_URL_260}".indexOf("/services")); 
var url = baseUrl +"/services/apexrest/SpringCMEos/eosinfo?objecttype="+objecttype+"&objectid="+objectid; 
var authkey = "Bearer {!$Api.Session_ID}"; 

sforce.connection.remoteFunction({ 
url : url, 
requestHeaders: {"Authorization":authkey,"Accept":"application/json"}, 
onSuccess : function(response) { 
var eosInfoResponse = JSON.parse(response); 
callback(eosInfoResponse); 
} 
}); 
} 


//Here you write your own code, this is a simple call 
var objectid = "{!Opportunity.Id}"; 
var objecttype = "Opportunity"; 

getEOSInfo(objectid,objecttype,function(eosInfo){ 


var formuid = "8be07531-XXXX-e611-XXXX-6c3be5a7XXXX"; 
var url = "https://XXX21.springcm.com/atlas/Forms/UpdateFormDoc.aspx?aid=9723&FormUid=" + formuid + "&SFFTE={!Opportunity.FTEs__c}&SFIND={!Account.Industry}&SFPSD={!Opportunity.ProgramStartDate__c}&SFID=" + eosInfo.SFId + "&SFNAME={!Opportunity.Name}&SFWF=ABC&SFCAFTYPE=CAAF&SFTYPE=Salesforce.Opportunity&SFPATH=" + eosInfo.FolderPath + "&ru=%2Fatlas%2Fbpm%2FWorkList.aspx"; 

window.open(url); 

});

Your help is greatly appreciated.
Hello,

In LE, I created an action in order to create an asset, which is related to an opportunity. The action button is located at the top right side in the opportunity detail view. The action works very well, but it stays on the opportunity. Is it possible to customize the return URL, so that it redirects the user to the created asset?