• mukesh gupta
  • ALL STAR
  • 6851 Points
  • Member since 2015
  • 9X Salesforce Certified
  • hcl

  • Chatter
    Feed
  • 205
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 122
    Questions
  • 1558
    Replies
Opportunity 1 was created by User 1 whose Role is 'Account Manager' and whose profile is 'Standard User'

When I do an API call using User 2 credentials, to get all the opportunities, Opportunity 1 is not returned in the list.
User 2 Role is 'Developer' and the Profile is 'System Administrator.

Per your documentation, I have changed the Sharing setting of OPPORTUNITY to allow Developers to see all the opportunities created by an Account Manager.
But I still cannot see it.
Hi,

Lightning data table not pulling the data. rows are comming as blank. I am trying to display the picklist values of Type field on the account. Code below:

HTML File:
<template>
            <lightning-datatable
            key-field="Id"
            columns={columns}
            data={picklistValues.data.values}>
    
            </lightning-datatable>


</template>

JS File:
import {
    LightningElement,
    wire
} from 'lwc';
import {
    getPicklistValues
} from 'lightning/uiObjectInfoApi';
import TYPE_FIELD from '@salesforce/schema/Account.Type';


export default class Picklistvalues extends LightningElement {

    columns = [
        { label: 'Id', fieldName: 'Id', type: 'Id' },
        { label: 'Account Type', fieldName: TYPE_FIELD.fieldApiName, type: 'text' }
    ];


    @wire(getPicklistValues, {
        recordTypeId: '012o0000000qnHlAAI',
        fieldApiName: TYPE_FIELD,
    })
    picklistValues;
}
Hi All,

I want to create one aura component where it should re-direct based on Users region. For e.g if user is from USA region(country) and when he try to click on link it should redirect to web page and when a user from Japan login and click on that component link it should be redirected to diffrent web page.
Please help me with this.

Thanks,
Anurag
 
Whenever trying to execute the below code I am getting the error:


global class batchclass implements Database.Batchable<sObject>,Database.Stateful{
    global integer countopp;
    global Decimal sumamount;
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        String query='Select id, Customer_segment__c ,(select accountid,amount,Stagename,Createddate from Opportunities) from Account Limit 500';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Account> lstacc)
    {
         AggregateResult[] gr= [SELECT Accountid,SUM(Amount) optyamt,Count(Id) cid FROM Opportunity Where Accountid IN:lstacc Group by Accountid];
    
    for(AggregateResult ag:gr){
        sumamount = (Decimal)ag.get('optyamt');
        countopp=(integer)ag.get('cid');
    }

        for(account acc:lstacc){
            if(sumamount<50000 && countopp>1){
                        acc.Customer_segment__c = 'Hot';
            }
            else if(sumamount>=50000 && countopp>1){
                        acc.Customer_segment__c = 'Medium';
            }
             else{
            acc.Customer_segment__c = 'Low';
        }
        update lstacc;
    }
    }
    global void finish(Database.BatchableContext BC){
        system.debug('finish'); 
    }
}
I want to calculate Roll up summary for Closed Won Opportunities for the current year. How do achieve this?
Hello there so below I did get the ageing days but i want to get hours too can someone help please
TEXT(

CASE(MOD( DATEVALUE(LastModifiedDate) - DATE(1985,6,24),7),
0 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),
1 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),
2 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),
3 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),
4 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),
5 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),
6 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),
999)
+
(FLOOR(( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) )/7)*5)
)& " Day"
Hello,

Yet another admin getting over their head in a foray into Apex.  I wrote a visualforce page (Cutting_ItemsShown) that required a custom controller (CuttingItemsShownController).  The VF page displays a list of associated records to the Task based on the Cutting_ID__c field on the Products_Cutting__c object.  These two parts work well, the trouble comes when trying to write a test class for the controller.
 
@isTest 
public class CuttingItemsShownControllerTest 
{
    static testMethod void testMethod1() 
    {   Account testAccount = new Account();
        testAccount.Name = 'Test Account';
        insert testAccount;
        
        Task testTask = new Task();
        testTask.RecordTypeId='0120y000000IBKkAAO' ;
        testTask.Subject='Cutting';
        testTask.Who_did_we_cut_against__c='Competitor';
        testTask.Did_We_Win__c='Yes';
        testTask.Whatid = 'testAccount.id';
        insert testTask;
        
        Products_Cutting__c item = new Products_Cutting__c ();
        item.Cutting_ID__c = testTask.id;
        item.Product_Code__c = '01tC0000004OvjpIAC';
        item.Name = 'SKUCode';
        item.Flavor__c = 'Company';
        item.Yield__c = 'Company';
        item.External_Texture__c = 'Company';
        item.Internal_Texture__c = 'Company';
        item.Cooked_Color__c = 'Company';
        item.Hold_Time__c = 'Company';
        item.Length__c = 'Company';
        item.Defects_Appearance__c = 'Company';
        item.Competitor_Item__c = '1234567901234';
        item.account_name__c = testAccount.Name;
        insert item;
        
        contract contr = new contract();
        // add all required field
        
        Test.StartTest(); 

            //ApexPages.currentPage().getParameters().put('id', String.valueOf(testTask.id));
            //CuttingItemsShownController  test = new CuttingItemsShownController(ApexPages.StandardController(testTask));
            //ApexPages.StandardController sc = new ApexPages.StandardController(item);
            //CuttingItemsShownController  testCutting = new CuttingItemsShownController(ApexPages.CuttingItemsShownController(testTask));
            PageReference pageRef = Page.Cutting_ItemsShown;
            pageRef.getParameters().put('Cutting_Id__c', testTask.id );
            pageRef.getParameters().put('Product_Code__c', '01tC0000004OvjpIAC');
            Test.setCurrentPage(pageRef);

            CuttingItemsShownController testTask1 = new CuttingItemsShownController(new ApexPages.StandardController(testTask));
            testTask.redirPage();    
        Test.StopTest();
     


            testCutting.cancel(); 
            testCutting.add ();

        Test.StopTest();
    }
}

The error received is as in the title:
Error: Compile Error: Constructor not defined: [CuttingItemsShownController].<Constructor>() at line 47 column 53

I'm thinking this has to do with the fact I'm displaying a list, but I'm not sure how to resolve it.  Is there any direction or resources you can provide to help me better understand the problem and the solution?  Thank you.
Q->  Insert 100 student’s records. Rollback all the inserted records if the number of successful insertion is less than 80
Please write code for the below problem....
Insert 5 records in Account object and display the list of records which are successfully inserted.Create related contact and opportunity to those successful accounts and add an opportunity product to those opportunity.. Using dml...
how to add opportunity product to opportunity
Thank you in advance
Hi all
It's really urgent I am totally new to coding I want to import my excel file to my custom object Sample__c to create new records using visual force page but even after searching, I am unable to complete it and am totally stuck.
I have an excel file with columns Name, Email, Phone and need to import the values to Sample__c fields Name__c, Email__c, Phone__c but can't do this any help from experts as I already followed all the links related to this now I need full code.
Thanks
Hi , I am new to salesforce, I have a below scenario, I just wanted to know whether I nned to create a multiple approval processes or can I create one and do the required 


If the Account’s Annual Revenue is > 0, then it will assign to “Initial Approval User” (Queue). If the Initial Approval User approve the case then it will go to next steps else it will be final rejection and update the case status to Rejected, if the Initial Approval User reject the case.

If the Account’s Annual Revenue is > 500, then it will assign to “Immediate Approval User” (Queue). If the Immediate Approval User approve the case then it will go to next steps else it will be final rejection and update the case status to Rejected, if the Immediate Approval User reject the case.
If the Account’s Annual Revenue is > 10,000, then assign it to “Yourself”. If the you approve the case then it will update the case status to Closed else it will be final rejection and update the case status to Rejected, if the Immediate Approval User reject the case. (mandatory)



Thanks & Regards
Suhaas

 
With a button, wheter inside a dashboard or a action? I want to redirect the user to a aura component that is at the bottom of  the page.
TEMPLATECODE:
<template>
    <lightning-card title="Create custom lookup on contact object" >
   
        <div class="slds-p-horizontal_small">
            <c-lwc-product-lookup onselected={myLookupHandle}></c-lwc-product-lookup>
            <c-lwc-quotes-lookup onselected={myQuoteLookupHandle}></c-lwc-quotes-lookup>
           
            <lightning-input label="Sales Price"
                             value={quoteRecord.salesprice}
                             onchange={handleSalesChange}
                             class="slds-m-bottom_x-small slds-p-horizontal_small slds-form-element">
            </lightning-input>                        
            <lightning-input label="Quantity"
                             value={quoteRecord.quantity}
                             onchange={handleQuantityChange}
                             class="slds-m-bottom_x-small slds-p-horizontal_small slds-form-element">
            </lightning-input>
            <lightning-input label="Discount"
                             value={quoteRecord.discount}
                             onchange={handleDiscountChange}
                             class="slds-m-bottom_x-small slds-p-horizontal_small slds-form-element">
            </lightning-input>            
           
            <lightning-button label="Submit"
                              variant="brand"
                              onclick={createLookupContactAction}
                              class="slds-m-bottom_x-small slds-p-horizontal_small slds-form-element">
            </lightning-button>                    
        </div>
   
</lightning-card>
</template>

JSCODE:
import { LightningElement,track } from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';

import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
 import QUOTE_LINE_OBJECT from '@salesforce/schema/QuoteLineItem';
import salesPriceField from '@salesforce/schema/QuoteLineItem.UnitPrice';
import  quantityField from '@salesforce/schema/QuoteLineItem.Quantity';
import discountField from '@salesforce/schema/QuoteLineItem.Discount';
import productfieldId from '@salesforce/schema/QuoteLineItem.Product2Id';

import quotefieldId from '@salesforce/schema/QuoteLineItem.QuoteId';

export default class TESTDEAFYULTQUOTESAVE extends NavigationMixin(LightningElement) {
    @track selectedProductId;
    @track selectedQuoteId;
    @track selectedpriceBookEntryId;
    @track quoteId;  
    @track quoteRecord={
       
        salesprice:salesPriceField,  
        quantity:quantityField,
        discount:discountField
    }
   
       
        handleSalesChange(event)
        {
            this.quoteRecord.salesprice=event.target.value;
            window.console.log('salesprice==>'+this.quoteRecord.salesprice);
        }
        handleQuantityChange(event)
        {
            this.quoteRecord.quantity=event.target.value;
            window.console.log('quantity==>'+this.quoteRecord.quantity);
        }
        handleDiscountChange(event)
        {
            this.quoteRecord.discount=event.target.value;
            window.console.log('discount==>'+this.quoteRecord.discount);
        }
        createLookupContactAction(){
            console.log(this.selectedProductId);
            console.log(this.selectedQuoteId);
            const fields = {};
            fields[salesPriceField.fieldApiName] = this.quoteRecord.salesprice;
            fields[quantityField.fieldApiName] = this.quoteRecord.quantity;
            fields[discountField.fieldApiName] = this.quoteRecord.discount;
            fields[productfieldId.fieldApiName] = this.selectedProductId;
            fields[quotefieldId.fieldApiName]=this.selectedQuoteId;
            fields[pricebookEntryIdField.fieldApiName]=this.selectedpriceBookEntryId;
            const recordInput = { apiName: QUOTE_LINE_OBJECT.objectApiName, fields };
            createRecord(recordInput)
                .then(contactobj=> {
                    this.quoteId = contactobj.id;
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Contact record has been created',
                            variant: 'success',
                        }),
                    );
                    this[NavigationMixin.Navigate]({
                        type: 'standard__recordPage',
                        attributes: {
                            recordId: contactobj.id,
                            objectApiName: 'QuoteLineItem',
                            actionName: 'view'
                        },
                    });
   
   
   
                })
                .catch(error => {
   
 console.error("error: " + JSON.stringify(error));

                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Error creating record',
                            message: error.body.message,
                            variant: 'error',
                        }),
                    );
                });          
                }
    myLookupHandle(event){
        console.log(event.detail);
        this.selectedProductId = event.detail;
    }
    myQuoteLookupHandle(event){
        console.log(event.detail);
        this.selectedQuoteId = event.detail;
    }
}

ERROR WAS:
error: {"status":400,"body":{"message":"An error occurred while trying to update the record. Please try again.","statusCode":400,"enhancedErrorType":"RecordError","output":{"errors":[],"fieldErrors":{"PricebookEntryId":[{"constituentField":null,"duplicateRecordError":null,"errorCode":"REQUIRED_FIELD_MISSING","field":"PricebookEntryId","fieldLabel":"Price Book Entry ID","message":"Required fields are missing: [PricebookEntryId]"}]}}},"headers":{}}

Basically Ineed PriceBookEntryId which is missing How this field will added please tell me answer 

Thanks
Saurabh
Hi Everyone,
How to display JSON data by serializing in apex and display in descending order. Please have a look below json data.

let jsonData = [
{‘HouseName’:‘anna’,
‘Kilometers’:75
},
{‘HouseName’:‘nancy’,
‘Kilometers’: 55
},
{‘HouseName’:‘sana’,
‘Kilometers’:95
},
]

By getting this data from FE, parse it in apex, and provide list of housenames based on kilometers in descending order.

O/P-should be- [Sana,Anna,Nancy]
Please help me in Apex code.
Hello,
how are the licences claasified as per the amount and what are the best practices to do it, please ?


thank you for suggestion
Hello,
In my org many users are connecting with the salesforce licneces and many users are using same id for connection.
I wanted to implement MFA and how will this impact these usrs please 

and i have techncial users or API uers, how this will impact hem too