• Abdul Khatri
  • PRO
  • 3522 Points
  • Member since 2015

  • Chatter
    Feed
  • 113
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1029
    Replies
Hello all,
I am trying to show another div based on a checkbox toggle but its not working.  I tried using the aura:if but the div never renders.  I am able to use the aura:if is true in other places on the form but not for the checkbox toggle.  
<div class="modalCheckContainer">
                <span>
                    <label class="slds-checkbox--toggle slds-grid checkbox-left">
                        <span class="slds-form-element__label slds-m-bottom--none">file attached?</span>
                        <input id="attfile__c" type="checkbox" name="checkbox"
                            aria-describedby="fileattatoggle" value="{!v.fileatttoggle}" />
                        <span id="Toggle" class="slds-checkbox--faux_container" aria-live="assertive">
                            <span class="slds-checkbox--faux"></span>
                            <span class="slds-checkbox--on"></span>
                        </span>
                    </label>
                </span>
        </div>

Cheers,
P
I am writing an after-insert trigger on the Case object.  I am looking to send an email to one of two people depending on a field that is a child of the Account object.  A sibling to Case.  In my journey I have found that it is not possible to query a sibling (correct me if I'm wrong).  So I've decided,  once I have the Case, I will take the AccountId and do all of my logic and querys from there.

CustObject_Chld2Acct.fieldname - Child to Account, sibling to Contact
 
List<AggregateResult> AggregateResultList = [SELECT AccountId, Account.Name name, COUNT(Id) co, 
                                    FROM Case
                                    WHERE CreatedDate = LAST_N_DAYS:5
                                    GROUP BY AccountId, Account.Name
                                    HAVING COUNT(Id)  >= 8];
                       
        Set<Id> accIdSet = new Set<Id>();
        for(Case c: AggregateResultList) {
        if(c.AccountId != null) {
           System.debug(c.AccountId);
           // Now i have the Account ID, what do I do?  
           //Need to access fields in Account Object (Parent)
           //Need to access fields in CustObject_Chld2Acct          
        }

 

Hi,

I'm creating a Unit Test for a method that calls to another callout method.

I got the following error: Methods defined as TestMethod do not support Web service callouts

I've already created the Unit Test for the callout method and everything works OK.

How could I do it?

cass a{

public mycalloutmethod(url){ return Response.body}

public mymethodfortesting(){
String a = mycalloutmethod('myurl');
do something else
}
}

Thanks,
Pedro

 
I have a batch job that is giving me an error when I use the execute anonymous window. Any ideas of what this coud be? 
global class ServiceAppointmentCancel implements Database.Batchable<SObject>, Schedulable{ global Database.QueryLocator start(Database.BatchableContext BC) { String subject = 'Reload'; String status = 'O'; Date scheduledEnd = Date.today(); String query = 'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment ' + ' WHERE subject = : ' + subject + ' AND status = :' + status + ' AND scheduledEnd < ' + scheduledEnd; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<ServiceAppointment> serviceAppointments) { // Loop to iterate over the service appointments for(ServiceAppointment service : serviceAppointments) { service.status = 'C'; } // Preforming the DML operation update serviceAppointments; } global void finish(Database.BatchableContext BC) { } global void execute(System.SchedulableContext SC) { Database.executeBatch(new ServiceAppointmentCancel(), 200); } }

String q = 'SELECT Reload, O, Date.today()'; Database.executeBatch(new ServiceAppointmentCancel(), 200);

User-added image
 
Hi All,
Can anybody help me to write a test class for the below apex class.
public class MobileShopeeClass{
public static void NewCustomerDiscount(list<Mobile__c>MobileList1){
for(Mobile__c m:MobileList1){
if(m.Brand__c=='Samsung'){
m.Price__c=m.Price__c-(m.Price__c*10)/100;
m.Discount_status__c='You have got 10 % Discount!!';
}
else if(m.Brand__c=='Apple')
{
m.Price__c=m.Price__c-(m.Price__c*20)/100;
m.Discount_status__c='You have got 20 % Discount!!';
}
}
}
public static void OldCustomerDiscount(list<Mobile__c>MobileList2){
for(Mobile__c m:MobileList2){
if(m.Brand__c=='Samsung'){
m.Price__c=m.Price__c-(m.Price__c*5)/100;
m.Discount_status__c='You have got 5% Discount!!';
}
else if(m.Brand__c=='Apple')
{
m.Discount_status__c='Sorry,no discount!!';
}
}
}
I have a batch apex job that basically goes through all invoices and totals the amounts for each sales person for each month and year.  The job works as expected in the sandbox environment with the test data I created.  But when I moved the job to production, it runs without errors, but does not update the fields with the monthly invoice sum totals like it does in sandbox.  In reviewing the logs I found one for example that found totals and shows that it updated the fields for the months.  Then in the very next log that did not find any invoices with totals, it updated the fields with null values for the very same records as in the prior log.  The Forecast and Forecast detail objects were created from scratch for this batch job and have no other triggers or processes running against them to udpate any fields.  My code is below, can anyone see why it is not updating the sum fields properly?

global with sharing class Forecast_Batch implements Database.Batchable<sObject>, Database.Stateful{

        global Database.QueryLocator start(Database.BatchableContext BC)
        {
            return Database.getQueryLocator([SELECT Id,OwnerId FROM Account]); //Query all accounts for ID and OwnerId
        }

    global void execute(Database.BatchableContext BC, List<SObject> scope)
    {        
        Map<Id, Map<String,Decimal>> accountAmountMap = new Map<Id,Map<String,Decimal>>();

        List<Id> accountOwnerIds = new List<Id>();
        Set<Id> accountIds = new Set<Id>();
        
        system.debug('+++ SCOPE SIZE ' + scope.size());
        
        for (SObject s : scope) {
            
            Account acc = (Account)s;
            if(!accountIds.contains(acc.Id)){
                accountIds.add(acc.Id);
            }
            
        }
        
        for (Account acc : [SELECT OwnerId,(SELECT Amount__c,InvoiceDate__c,OwnerDetails__c,Inv_Yr__c FROM Invoice__r ) FROM Account WHERE Id in : accountIds]) {
            
            Map<String, Decimal> amountMap = new Map<String, Decimal>();
            
            for (Invoice__c inv : acc.Invoice__r) {
                 
                Decimal amount = amountMap.get(inv.OwnerDetails__c);
                if (amount != null) {
                    amountMap.put(inv.OwnerDetails__c, inv.Amount__c + amount); 
                } else {
                    amountMap.put(inv.OwnerDetails__c, inv.Amount__c); 
                }
            }
            accountAmountMap.put(acc.Id, amountMap);
            accountOwnerIds.add(acc.OwnerID);
            
        }
        System.debug(accountOwnerIds);

         // Query list of forecast details record based on Account's owner Id

        List<Forecast_Details__c> forecastdetails = [SELECT ID,Name,Month_Total__c,OwnerID__c,FDOwnerDets__c from Forecast_Details__c where OwnerID__c IN : accountOwnerIds];

        // Iterate accounts in for loop
        // iterate forecast details record
        // get invoice amount based on account id and forcast month.
        // update in forecast detail record.

        for (SObject s : scope) {
            Account acc = (Account)s;
            Map<String, Decimal> amountMap = accountAmountMap.get(acc.Id);
            for (Forecast_Details__c forecastDet : forecastdetails) {
                if (forecastDet.OwnerID__c == acc.OwnerId)
                    
                {
                    Decimal amount  = amountMap.get(forecastDet.FDOwnerDets__c);  
                    forecastDet.Month_Total__c = amount;
                    System.debug('match');
                    System.debug(amount);
                }
            }
        }
        System.debug(forecastdetails);
        update forecastdetails;
    }  

    global void finish(Database.BatchableContext BC){}



I really appreciate any assistance that anyone can provide!
Hi!

I have the query below in the controller of one of my visualforce pages:
 
SELECT Id, Name, Title, Company, Country, CreatedDate, Status FROM Lead WHERE Status='New' AND OwnerId= :UserInfo.getUserID() ORDER BY CreatedDate DESC

What I would like to do some kind of outer join to check if the Lead.Company field exists as a Account.Name so I can show this on the Visualforce page.

Any ideas on how to do this?
I'm attempting to create a note for an opportunity via the REST API.  I'm finding several examples for the SOAP API, but nothing that works using REST.  Using this API I am able to create a note, but can find no way to associate it with an opportunity ID:

https://developer.salesforce.com/docs/api-explorer/sobject/Note

Any help would be greatly appreciated.

Hi Guys,

I am triggering a POST request via process builder and it works but can you please tell me how can I capture the HTTP response I get back? The external system will send me a string I would like to store on the record which started the process. 
 

@future(callout=true)

        public static void calloutmethod(String name){
                Http http = new Http();
                HttpRequest request = new HttpRequest();
                request.setEndpoint('XXX');
                request.setMethod('POST');
                request.setHeader('Content-Type', 'application/json;charset=UTF-8');
                request.setHeader('accept', 'application/json');
                request.setBody(name);
                
                response = http.send(request);
        }

Thanks a lot.

Krisz
Hi,

I am having a massive confusion,

We have a database of 400,000 records.. which calls for duplication.

I want to check if alternate phone number of any of the account matches with the Primary phone number of any of the account, If it does, there is a checkbox  called "Marked For deletion"  m that checkbox should get selected and primary phone number of that account should become the alternate phone number of the acount against which it has matched 

So lets say ,

Accoount : A  Primary No : 1234  Secondary No : 5678

Accoount : B  Primary No : 9241  Secondary No : 1234 

Accoount : C  Primary No : 9241  Secondary No :  1234

Account B and Account C should have marked for deletion checked.
and Account B's primary phone number should become Secondary phone number of Account A. 

Please help me in achieving this 
 
I need to update the Account Name (Account_Name__c) custom field in the Task tab, with the Account Name (AccountId). My current code is:

trigger Account_Name on Task (before insert, before update) {
    for(Task a : trigger.new) {        
        task.Account_Name__c = a.AccountId;
    }
}


I keep receiving an error that says: A value cannot be stored to Account_Name__c in type task. What am I doing wrong?
I have been asked to make a custom weighting option for one of the smaller businesses in our org. 

If the sales manager picks one of the following picklist options during his opportunity creation, the formula should calculate as appropriate:

Custom Opp Weighting Picklist
Existing client, existing product =  divide opportunity amount by 2
Existing client, new product = divide opportunity amount by 3
New client, existing product = divide opportunity amount by 5
New client, new product = divide opportunity amount by 10

Is there an esy way I can I achive this via a picklist? 

Would really appreciate any help!
 
We need to simulate running monthly scheduled batch apex jobs over multilple months/year to see mutiple records instances being recaluculed over time.

I can see that there are some comments from 2011 saying that this is not possible but just wanted to check in 2019? I am guessing not but just thought to ask.
Hello.
I can get user and public groups from public groups this SOQL,
but public groups add role, can not get add role.
How to get role from public groups?
[SELECT Id, DeveloperName, (SELECT UserOrGroupId FROM GroupMembers)
FROM Group WHERE DeveloperName IN :xxxxxx]
Have a picklist with 10 values, when it is picklist option 2 or 3, i want to check to see if a number field is not null.

NOT ( OR ( ISPICKVAL ( FieldName__c , "Option 2" ), ( ISPICKVAL ( FieldName__c , "Option 3" ) ) ) && NOT ( ISNULL ( NumberField__c ) = true ) )

It validates, but no matter what option 2 or 3 I pick, i can also put numbers in the number field and nothing seems to be stopping me from doing anything....
Hello Team,

While doing the trailhead for Quick Start - Apex Coding for Admins - Create a Trigger, while I am creating the candidate Nina Simone, and update the ZIP Code field as "20008", system gives me an error message stating as - Candidate Zip Code does not exist in specified State.

Kindly advise where I am going incorrect.

Thanks
Vinay Kumar Salve
Hi,

When a Campaign Member is removed from a campaign, it updates the IsDeleted flag, but does anyone know if this also updates the Last Modified date on the Campaign Member?

Thanks,

Kam
I am having trouble with a valdiation formula that checks two sets of criteria.
Criteria 1 - Field A = Yes AND Field B's number field is greater than 0.
Criteria 2 - Field A = Yes AND Field B's number field is greater than 0 AND Field C = Yes AND Field D not equal to BLANK

The first and second criteria reference the same elements but should be independent of each other. My formula "seems" to workfor Criteria 2 but not 1.

AND( NOT(ISPICKVAL(Furniture_Delivered_Model_Setup__c, 'No')), Attachment_Added__c>0, OR( AND( NOT(ISPICKVAL(Virtual_Tour__c, 'No')), NOT(ISBLANK(Model_Promo_Virtual_Tour__c)), NOT(ISPICKVAL(Furniture_Delivered_Model_Setup__c, 'No')), Attachment_Added__c>0) ))

Any help is greatly appreciated
  • February 20, 2019
  • Like
  • 0
Hello - How can I return a lead list called 'returnedLead' from a class to a trigger. Any assistance would be greatly appreciated. 

Trigger:
if(Trigger.isUpdate){
                   //Passing Trigger.new and Trigger.old to LeadOwnerAssignment class
                    LeadOwnerAssignment.leadChanges(Trigger.new, Trigger.old);
}

Class: 
public class LeadOwnerAssignment {
    
    public static void leadChanges(List<Lead> newLead, List<Lead> oldLead){
        
        List<Lead> returnedLead = new List<Lead>();
        
        //Old Lead Map
        Map<String, String> mapOfOldAffinityType = new Map<String, String>();
        
        for(lead oldLds : oldLead) {
            mapOfOldAffinityType.put(oldLds.Affinity_Type__c, oldLds.LastNameStreetAndZipCode__c);
        }

        for(Lead ld : newLead) {
            if(ld.Affinity_Type__c != mapOfOldAffinityType.get(ld.Affinity_Type__c)){
                returnedLead.add(ld);     
            }
        }  
    }            
}

I have turned on "Associate a Contact with Multiple Accounts".  I use a visualforce page to display my accounts and I'm trying to figure out the name of the related list to use.  

I used AccountContactRoles but I'm not getting the right page layout or buttons as expected.  thanks!!! 
 

Fred

  • February 20, 2019
  • Like
  • 0
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
Can someone help me to show how I can change the Sales Console Lightning Layout. Currently it is showing as shown in the screen shot below as 3 Column layout. I wanted to change the layout to show the highlight panel on top. I am finding no help from Salesforce help section or trailhead for this. Please bear in mind I am talking about Lightning Sales Console and not Classic. I did the Edit Page and takes me but doesn't allow me to change the layout. 

User-added image
Is there a way to hide "Save & New" Button from the Task page Layout?

User-added image

I looked at everywhere and couldn't find the solution. I do want to give them Create/Edit Permission so no option there to remove that.

Please help
Custom URL for the cast creating inline headers and side bar. I tried the following addition things

            urlConcat += '&inline=0';
            urlConcat += '&isdtp=lt';
            urlConcat += '&isdtp=nv';
            urlConcat += '&isdtp=vw';

the only one that work is '&isdtp=nv' but after saving the activity, the hyperlink in the related list doesn't work. I have attached a screen shot 

User-added image

Anyone can help?

 
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
I am trying to execute an apex test class and throws me this error after this long runing and thee error pops up. as . salesforce common.exception sfdc.sqltimeoutexception:ORA-01013: user requested cancel of current operation
Hello all,
I am trying to show another div based on a checkbox toggle but its not working.  I tried using the aura:if but the div never renders.  I am able to use the aura:if is true in other places on the form but not for the checkbox toggle.  
<div class="modalCheckContainer">
                <span>
                    <label class="slds-checkbox--toggle slds-grid checkbox-left">
                        <span class="slds-form-element__label slds-m-bottom--none">file attached?</span>
                        <input id="attfile__c" type="checkbox" name="checkbox"
                            aria-describedby="fileattatoggle" value="{!v.fileatttoggle}" />
                        <span id="Toggle" class="slds-checkbox--faux_container" aria-live="assertive">
                            <span class="slds-checkbox--faux"></span>
                            <span class="slds-checkbox--on"></span>
                        </span>
                    </label>
                </span>
        </div>

Cheers,
P
I have a HTTP Request that sends out an endpoint to an Azure function. I've added the endpoint url to Remote Site Settings. When I send the request in Postman, I get a 200 OK status. When I send this request from Salesforce, I get a 400 Bad Request. 

I have tried to set Content-Type and Accept to application/json but keep getting the 400 error and the response header as text/plain (see debug log). 

Why isn't the response header Content-Type set to application/json? Is there any other way to make sure the response is being returned as application/json? This is my first time with an http request so if I'm missing something or if you have any ideas on a fix, I would be super grateful! 
public static Boolean mergeTest(String masterId, String followerId){

       JSONGenerator gen = JSON.createGenerator(true);    
        gen.writeStartObject();      
        gen.writeStringField('is_sandbox', String.valueOf(Utils.runningInASandbox()));
        gen.writeStringField('master',masterId);
        gen.writeStringField('follower',followerId);
        gen.writeEndObject();    
        String jsonS = gen.getAsString();
        String endpoint = 'https://xxxxxxxxxxx.azurewebsites.net/api/FunctionName?code=defaultFunctionKey==';
        HttpRequest req = new HttpRequest();
        req.setEndpoint(endpoint);
        req.setMethod('POST');
        req.setbody(jsonS);
        req.setHeader('x-functions-key', 'masterHostKey');
        req.setHeader('Content-Type','application/json');
        req.setHeader('Accept', 'application/json');
        Http http = new Http();
        req.setTimeout(120000);
        HTTPResponse response;
        if (!Test.isRunningTest()){
            try{
                response = http.send(req);
                if (response.getStatusCode() == 500) {
                    return False;
                }
            } catch (System.Exception e){
            	System.debug('Callout exception error: '+e);
            }      
        }       
        return True;
    }
Screen shot
Create the following visualforce page and name it "TestListPage":
 
<apex:page id="TestListPage" standardController="Lead" recordSetVar="records" >

<apex:includeScript value="/support/console/47.0/integration.js"/>

<script>

function openTab(){
sforce.console.openPrimaryTab(null, '/apex/TestListPage', true, 'PrimaryTab', function(result){
console.log(result);
});
}

</script>

<button onClick="openTab()">New Tab</button>

</apex:page>

Go to Setup -> Object Manager -> Lead -> Buttons Links and Actions and override the List action with the page you just created.

In lightning experience, go to the Sales Console and select Leads in the navigation menu.

Your new page should appear instead of the normal lead list. Click the "New Tab" button on the page.

A new console tab should open with the same page in it. In the javascript console, you'll notice a success message.

In this list on the left, click the "New Tab" button again. This time, the new tab will not open and you will see the following error message: "Error: Invalid request."


It appears to me that the salesforce console api breaks completely in the list side of the page once a console tab loads integration.js


A member of the Salesforce Technical Support team assured me that if I posted this here that Salesforce's Developer Experts would review my post and create a Known Issue.  I look forward to your responses!
I am writing an after-insert trigger on the Case object.  I am looking to send an email to one of two people depending on a field that is a child of the Account object.  A sibling to Case.  In my journey I have found that it is not possible to query a sibling (correct me if I'm wrong).  So I've decided,  once I have the Case, I will take the AccountId and do all of my logic and querys from there.

CustObject_Chld2Acct.fieldname - Child to Account, sibling to Contact
 
List<AggregateResult> AggregateResultList = [SELECT AccountId, Account.Name name, COUNT(Id) co, 
                                    FROM Case
                                    WHERE CreatedDate = LAST_N_DAYS:5
                                    GROUP BY AccountId, Account.Name
                                    HAVING COUNT(Id)  >= 8];
                       
        Set<Id> accIdSet = new Set<Id>();
        for(Case c: AggregateResultList) {
        if(c.AccountId != null) {
           System.debug(c.AccountId);
           // Now i have the Account ID, what do I do?  
           //Need to access fields in Account Object (Parent)
           //Need to access fields in CustObject_Chld2Acct          
        }

 

Hi All,
     We are having an issue that any text area that is not being populated with a value is being dropped from the JSON.  Normally this would not be an issue but some of these fields are synced to SQL servers that are accessed by other web applications.  Has anyone else experienced this and what was the best resolution you found?
Hi,

I'm creating a Unit Test for a method that calls to another callout method.

I got the following error: Methods defined as TestMethod do not support Web service callouts

I've already created the Unit Test for the callout method and everything works OK.

How could I do it?

cass a{

public mycalloutmethod(url){ return Response.body}

public mymethodfortesting(){
String a = mycalloutmethod('myurl');
do something else
}
}

Thanks,
Pedro

 
I have a batch job that is giving me an error when I use the execute anonymous window. Any ideas of what this coud be? 
global class ServiceAppointmentCancel implements Database.Batchable<SObject>, Schedulable{ global Database.QueryLocator start(Database.BatchableContext BC) { String subject = 'Reload'; String status = 'O'; Date scheduledEnd = Date.today(); String query = 'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment ' + ' WHERE subject = : ' + subject + ' AND status = :' + status + ' AND scheduledEnd < ' + scheduledEnd; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<ServiceAppointment> serviceAppointments) { // Loop to iterate over the service appointments for(ServiceAppointment service : serviceAppointments) { service.status = 'C'; } // Preforming the DML operation update serviceAppointments; } global void finish(Database.BatchableContext BC) { } global void execute(System.SchedulableContext SC) { Database.executeBatch(new ServiceAppointmentCancel(), 200); } }

String q = 'SELECT Reload, O, Date.today()'; Database.executeBatch(new ServiceAppointmentCancel(), 200);

User-added image
 
Hi All,
Can anybody help me to write a test class for the below apex class.
public class MobileShopeeClass{
public static void NewCustomerDiscount(list<Mobile__c>MobileList1){
for(Mobile__c m:MobileList1){
if(m.Brand__c=='Samsung'){
m.Price__c=m.Price__c-(m.Price__c*10)/100;
m.Discount_status__c='You have got 10 % Discount!!';
}
else if(m.Brand__c=='Apple')
{
m.Price__c=m.Price__c-(m.Price__c*20)/100;
m.Discount_status__c='You have got 20 % Discount!!';
}
}
}
public static void OldCustomerDiscount(list<Mobile__c>MobileList2){
for(Mobile__c m:MobileList2){
if(m.Brand__c=='Samsung'){
m.Price__c=m.Price__c-(m.Price__c*5)/100;
m.Discount_status__c='You have got 5% Discount!!';
}
else if(m.Brand__c=='Apple')
{
m.Discount_status__c='Sorry,no discount!!';
}
}
}