• Dhilip Dussa
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 9
    Replies

Hi,

I have to two loop values in one loop how it is possible?

Ex:

List<Account> accList = [SELECT Id, Name FROM Account LIMIT 10];
List<Account> accList2 = [SELECT Id, Name FROM Account LIMIT 9 OFFSET 1];

for(){
String s = accList.name  + accList2.Name;
}

i want to pass in for loop one by one how it will be possible please help me.

Thanks,
Dhilip Dussa

Hi,

Here i want to calculate distance please help me.

I have few records and i have location filed reuirement is i have 5 records

A, B, C, D, E here i want distance between 
A to B , B to C, C to D, D to E how it will be possible? please help me.

Thanks,
Dhilip Dussa.
I'm trying for NonProfit SuccessPack 360 view data of donor. How can i do this please help me.   
 
Thanks,
Dhilip Dussa
Good Morning,

I facing an error in Batch class : 

Merge failed. First exception on row 0 with id 0030U00001ESVzyQAH; first error: LIMIT_EXCEEDED, System.LimitException: Too many queueable jobs added to the queue: 2: []

Code: 

global class MergeContactBatch implements database.Batchable<sObject>{
    
    String Name = '%Test%';
    global Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'SELECT Id FROM Contact WHERE Email = NULL AND Name LIKE \''+Name+'\'';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Contact> scope){
        
        Contact masterConact = MergeContactBatch.getContact();
        
        List<Contact> dupcontactList = new List<Contact>();
        Set<Id> Ids = new Set<Id>();
        for(Contact contactRecrd : scope){
            Ids.add(contactRecrd.Id);
            dupcontactList.add(contactRecrd);
        }
        
        List<Contact> contactList = [SELECT Id FROM Contact WHERE Id IN: Ids];
        for(Contact con : contactList){
            Database.merge(masterConact, con);
        }
        
       // Database.MergeResult[] results = Database.merge(masterConact, dupcontactList);
    }
    
    global void finish(Database.BatchableContext BC){}
    
    
    public Static Contact getContact(){
        
        List<Contact> contactList = [SELECT Id FROM Contact WHERE Id = '0030U00001ESW0S'];
        if(!contactList.isEmpty()){
            return contactList[0];
        }else{
            return null;
        }
    }
}

please help me,

Thanks,
Dhilip Dussa
Good Morning,

I'm integrating Salesforce and Twitter. Here i need User Access Token. How can I find this. please help if any one have idea on this.

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create

Thanks,
Dhilip Dussa.
Good Morning,

I'm facing one issue on Twitter integration

Error: {"errors":[{"code":32,"message":"Could not authenticate you."}]}

Request: curl --request POST --url 'https://api.twitter.com/1.1/friendships/create.json?user_id=2244994945&follow=true' --header 'authorization: OAuth oauth_consumer_key="YOUR_CONSUMER_KEY", oauth_nonce="AUTO_GENERATED_NONCE", oauth_signature="AUTO_GENERATED_SIGNATURE", oauth_signature_method="HMAC-SHA1", oauth_timestamp="AUTO_GENERATED_TIMESTAMP", oauth_token="USERS_ACCESS_TOKEN", oauth_version="1.0"' --header 'content-type: application/json'

My Code:

    public Static void followUser(){
        Twitter_API_Settings__c twitter = [SELECT Id, API_Key__c, API_Secret_Key__c, Access_Token__c, Access_Token_Secret__c 
                                           FROM Twitter_API_Settings__c LIMIT 1];
        String oathNonce = TwitterController.generateOathNonce();
        Long timestamp = TwitterController.generateTimeStamp();
        String signature = '';
        String othSecret = Encodingutil.urlEncode(twitter.Access_Token_Secret__c, 'UTF-8');
        String consumSecret = Encodingutil.urlEncode(twitter.API_Secret_Key__c, 'UTF-8');
        String othToken = Encodingutil.urlEncode(twitter.Access_Token__c, 'UTF-8');
        String othNonce = Encodingutil.urlEncode(oathNonce, 'UTF-8');
        String consumKey = Encodingutil.urlEncode(twitter.API_Key__c, 'UTF-8');
        String paramString = 'include_entities=true&'+
            'oauth_consumer_key='+consumKey+'&'+
            'oauth_nonce='+othNonce+'&'+
            'oauth_signature_method=HMAC-SHA1&'+
            'oauth_timestamp='+timestamp+'&'+
            'oauth_token='+othToken+'&'+
            'oauth_version=1.0';
        string baseString = 'POST&'+EncodingUtil.urlEncode('https://api.twitter.com/1.1/friendships/create.json', 'UTF-8')+'&'+ 
            EncodingUtil.urlEncode(paramString, 'UTF-8');
        string signString = consumSecret+'&'+othSecret;
        blob blobBaseString = Blob.ValueOf(baseString);
        blob blobSignString = Blob.ValueOf(signString);
        blob signBlob = crypto.generateMac('hmacSHA1',blobBaseString ,blobSignString );        
        signature =  EncodingUtil.base64Encode(signBlob);
        System.debug('signature=====>>>>>>>'+signature);
        if(String.isNotBlank(signature))
        {
            signature = Encodingutil.urlEncode(signature, 'UTF-8');
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://api.twitter.com/1.1/friendships/create.json?screen_name=s_cheera&follow=true');
            req.setMethod('POST');
            string reqstring = 'OAuth oauth_consumer_key="'+consumKey+'",'+
                'oauth_nonce="'+othNonce+'",'+
                'oauth_signature="'+signature +'",'+
                'oauth_signature_method="HMAC-SHA1",'+
                'oauth_timestamp="'+timestamp+'",'+
                'oauth_token="'+othToken+'",'+
                'oauth_version="1.0"';
            system.debug('### req String :'+reqstring);
            req.setHeader('Authorization',reqstring);
            req.setHeader('Content-Type','application/json');
           // String bearerAuthorizationHeader='Bearer '  + accessToken;
            //req.setHeader('Authorization',bearerAuthorizationHeader);
            Http http = new Http();
            HTTPResponse res = http.send(req);
            system.debug(res.getBody());            
        }
    }

please help me.

Thanks,
Dhilip Dussa.

Good Morning,

I'm integrating Salesforce and Twitter. I'm getting an error {"errors":[{"code":215,"message":"Bad Authentication data."}]}

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create

Please check code once

public class TwitterController {    
    
    public static String generateOathNonce(){
        Blob blobKey = crypto.generateAesKey(256);
        String key = EncodingUtil.convertToHex(blobKey);
        String oathNonce = EncodingUtil.base64Encode(Blob.valueOf(key));
        oathNonce = oathNonce.replaceAll('[^a-zA-Z0-9]+',''+integer.valueOf(math.random() * 10));
        oathNonce = oathNonce.substring(0,42);
        return oathNonce;
    }
    
    public static long generateTimeStamp(){
        long timestamp = datetime.now().getTime(); 
        timestamp = timestamp / 1000;
        return timestamp;
    }
}

============================================

public class TwitterTweetsCtrl {
public Static void createFavorites(){
        String accessToken = TwitterController.retrieveAccessToken();
        Twitter_API_Settings__c twitter = [SELECT Id, API_Key__c, API_Secret_Key__c, Access_Token__c, Access_Token_Secret__c 
                                           FROM Twitter_API_Settings__c LIMIT 1];
        Long timestamp = TwitterController.generateTimeStamp();
        String oathNonce = TwitterController.generateOathNonce();
        
        String consumKey = Encodingutil.urlEncode(twitter.API_Key__c, 'UTF-8');
        String othNonce = Encodingutil.urlEncode(oathNonce, 'UTF-8');

        String othToken = Encodingutil.urlEncode(twitter.Access_Token__c, 'UTF-8');
        String othSecret = Encodingutil.urlEncode(twitter.Access_Token_Secret__c, 'UTF-8');
        String consumSecret = Encodingutil.urlEncode(twitter.API_Secret_Key__c, 'UTF-8');
        String paramString = 'include_entities=true&'+
            'oauth_consumer_key='+consumKey+'&'+
            'oauth_nonce='+othNonce+'&'+
            'oauth_signature_method=HMAC-SHA1&'+
            'oauth_timestamp='+timestamp+'&'+
            'oauth_token='+othToken+'&'+
            'oauth_version=1.0';
        string baseString = 'POST&'+EncodingUtil.urlEncode('https://api.twitter.com/1.1/favorites/create.json', 'UTF-8')+'&'+ 
            EncodingUtil.urlEncode(paramString, 'UTF-8');

        string signString = consumSecret+'&'+othSecret;
        blob blobBaseString = Blob.ValueOf(baseString);
        blob blobSignString = Blob.ValueOf(signString);
        blob signBlob = crypto.generateMac('hmacSHA1',blobBaseString ,blobSignString );        
        String signature =  EncodingUtil.base64Encode(signBlob);
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('https://api.twitter.com/1.1/favorites/create.json?id=1412999372476981248');
        string reqstring = 'OAuth oauth_consumer_key="'+consumKey+'",'+
                'oauth_nonce="'+othNonce+'",'+
                'oauth_signature="'+signature +'",'+
                'oauth_signature_method="HMAC-SHA1",'+
                'oauth_timestamp="'+timestamp+'",'+
                'oauth_token="'+othToken+'",'+
                'oauth_version="1.0"';
        req.setHeader('Authorization',reqstring);
        req.setHeader('Content-Type','application/json');
        Http http = new Http();
        HTTPResponse res = http.send(req);
        system.debug(res.getBody()); 
    }
}

please help me,

Thanks,
Dhilip Dussa.

I need some help closing the sub-tab on Console view

I was created one button on the Account Record page. If I click on this button it will open a pdf file in a new sub-tab. in this sub-tab I have one cancel button if I click on this I need to close this sub tab. please help me.

Thanks,
Dilip Dussa.
Hi,

I'm facing one issue while inserting a record.

I have once Multi-select picklist,
if select anyone i need to create one more record with the same name

the first time it is inserting fine,
but if try next time getting an error
Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Special Initiative: id value of incorrect type: a4D6C000000DMXJUA4

please help me,

List<Contact> mrl = new List<Contact>();

for(Integer i=0; i<wrapperList.size(); i++){
            System.debug('mkList===========>>>>>>'+mkList);
            Contact mr = new Contact();
            mr.name = wrapperList[i];
            mr.Account = wrapperList[i];
            mr.Opportunity__c = recordId;
            mrl.add(mr);
        }
        if(!mrl.isEmpty()){
            Insert mrl;
        }

I'm inserting name with accountId only

Thanks,
Dhilip
Hi,

I have one logic in that logic i'm returning values i'm return values are

{"available":
    {
        "a4C6C0000005rsWUAQ":"Account Test 1",
        "a4C6C0000005y14UAA":"Account Test 2",
        "a4C6C0000005s0rUAA":"Account Test 3"
    },

"hidden":{"a4D6C000000GycrUAC":"Account Test 4"}

}

I need to separate this lightning javascript 

I need to set "available" will be one attribute and
hidden will be in another attribute.

please help me

thanks,
Dhilip
Hi good morning,

I Need help on Salesforce JWT

I was done this to return Access token, after this i need to send any message to another Salesforce org can anyone please help me on this 

Thanks,
Dilip
Is there any way to hide total URL

Dilip commented on https://login.salesforce/browse/JIP-123: this test comment.

Here I need to display: Dilip this test comment.
can you please help me.

Note: Some times URL will be different like https://login.salesforce/browse/JIP-12345:

Thanks
Dilip
Good Morning,

Here I need to remove one line from the feed item

I can remove the specific sting by using string.remove('Test'); like this

but I need to remove one line
 
Example: 
This is the Raju's first comment, please check updated comment

in this, I need to remove 'This is the Raju's first comment' up to here

Note: here name will not same every time user can mention any name but starting and ending letters will be same every time
please help me,

Thanks,
Dhilip

Hi,

Here I have a requirement to set the record as a primary record

currently, I'm using case object in that case object I created a picklist field values are True and false

I create any new case I would be the primary record need to update remaining records false I did it but

i perform before update operation any record need to update that record as primary = true remaining records will be false anyone please help me on this, please

public class CaseController {
    
    public static Boolean isFirstTime = true;
    
    public Static void setPrimary(List<Case> caseList){
        for(Case c : CaseList){
            c.Primary__c = 'True';
        }
    }
    
    public Static void updatePrimary(List<Case> caseList){
        Set<Id> cIds = new Set<Id>();
        Set<Id> conIds = new Set<Id>();
        
        for(Case c : caseList)
        {            
            cIds.add(c.Id);
            conIds.add(c.contactid);
            
        }
        List<Case> cRecords = [Select Id,Primary__c,contactId From Case Where ContactId In :conIds];
        
        List<Case> cToUpdate = new List<Case>();
            for(Case c : cRecords)
            {
                if(!cIds.contains(c.Id))
                {
                    if(c.Primary__c=='True')
                    {
                        c.Primary__c = 'False';
                        cToUpdate.add(c);
                    }
                }
            }
         if (!cToUpdate.isEmpty()){
            update cToUpdate;
         }
        }
}

Hi,
I need some help on rest api, i'm not getting how to conver the
--data-urlencode

curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACe3cba3a08d9584987ecb9dc41946b15c/IncomingPhoneNumbers.json \ --data-urlencode "PhoneNumber=+15017122661" \ -u ACe3cba3a08d9584987ecb9dc41946b15c:your_auth_token

In endpoint i added the curl -X
anyone please help me

Thanks,
Hi,

Need help on returning value

I have created a site with vf page i need to return the values

the requirement i receive any message from thirdparty i need to show that

public class ControllerContacts{

   public Class wrapper{
        @AuraEnabled Public String Messages;
        @AuraEnabled Public String frmNumber;
        @AuraEnabled Public String currentpage;
    }
    @AuraEnabled
    public Static list<wrapper> init(){
        list<wrapper> wrapperList = new list<wrapper>();
        wrapper q = new wrapper();
        q.currentpage = ApexPages.currentPage().getParameters().get('MessageUUID');
        q.Messages = ApexPages.currentPage().getParameters().get('Text');
        q.frmNumber = ApexPages.currentPage().getParameters().get('From');
        wrapperList.add(q);
        system.debug('wrapperList========>>>>'+wrapperList);
        String fromNumber      = ApexPages.currentPage().getParameters().get('From');
        String text            = ApexPages.currentPage().getParameters().get('Text');
        
        IF(fromNumber != NULL && text !=NULL){
            SreeBolt__Twilio_Messages__c twilio = new SreeBolt__Twilio_Messages__c(SreeBolt__From_Number__c = '+'+fromNumber,SreeBolt__Message__c = text);
            insert twilio;
        }
        return wrapperList;
    }
}

=============================================================
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" controller="ControllerContacts">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute type="List" name="Message"/>
    <aura:attribute type="List" name="Number"/>
    hello: {!v.Message}
    {!v.Number}
    <aura:iteration items="{!v.Message}" var="Msg">
        hello : {!Msg.Messages}
    </aura:iteration>
</aura:component>
=================================================================
({
    doInit : function(cmp, event, helper) {
        var action = cmp.get("c.init");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                cmp.set('v.Message', response.getReturnValue());
                cmp.set('v.Number', response.getReturnValue());
            console.log(cmp.get('v.Message'));
                console.log(cmp.get('v.Number'));
            }
        });
        $A.enqueueAction(action);
    }
})
Hi Everyone,

In need some help on command buttons

I created the text field and also created the button

if I enter any text and click on save button i need to disply the text
This is fine am able to the text

but i need to save it if i enter another text i need  both text values like n text values 

Thanks,
Dhilip
Hi,
I need Help on Test class with assert how to add assert in this test class

public class TestClass{
 @AuraEnabled
    public static Account returnAccount(Id ParentId) {
        return [Select Name, FirstName, LastName, Id from Account where id =: ParentId];
    }
    
    }
    ====================================================================
    @isTest
    public static void test(){
    Account a = new Account();
    a.Name='Test'
    insert a;
    
    TestClass.returnAccount(a.id);
    //need add assert here if I comment above line assert has to fail o/w it hass to pass
    }

Thanks
Hi,
I need help on displaying name
I need to display account records limit 10 by using lightning card 
I able to display this 10 records 
but I need to add one avather for every card account lastname firstletter and firstname firstletter 
anyone please help me on this
Thanks
This code is working fine but if i changed -91 to -90 r -92 then also one opportunity is creating can any one please fix this
    public static void insertOpportunity(list<OrderApi__Subscription__c> sub){
        
        set<id> ids = new set<id>();
        
        for(OrderApi__Subscription__c o : sub){
        
            ids.add(o.id);
        
        }
        
        
        list<Opportunity> op = new list<Opportunity>();

        for(OrderApi__Subscription__c o : [select id,OrderApi__Subscription_Plan__c,OrderApi__Days_To_Lapse__c,OrderApi__Contact__c,OrderApi__Contact__r.name,OrderApi__Item__c,OrderApi__Account__c from OrderApi__Subscription__c where id in : ids and (OrderApi__Item_Class__r.name='Silver Leader Membership' or OrderApi__Item_Class__r.name='Council Membership')]){
            
            if(o.OrderApi__Days_To_Lapse__c==-91){
                
                Opportunity opp = new Opportunity(Name=o.OrderApi__Contact__r.name,AccountId=o.OrderApi__Account__c,ContactId=o.OrderApi__Contact__c,StageName='Qualified',Type='Existing Business',CloseDate=system.today()+365,Probability=10);
                op.add(opp);
            }
        }
        
        if(op.size()>0){
        
            insert op;
        }
    }
===================================
if -91 hits i need to insert opportunity this one is working fine, if i updated -91 to any other number then also opportunity is creating please help me on this bug.
Is there any way to hide total URL

Dilip commented on https://login.salesforce/browse/JIP-123: this test comment.

Here I need to display: Dilip this test comment.
can you please help me.

Note: Some times URL will be different like https://login.salesforce/browse/JIP-12345:

Thanks
Dilip
Good Morning,

Here I need to remove one line from the feed item

I can remove the specific sting by using string.remove('Test'); like this

but I need to remove one line
 
Example: 
This is the Raju's first comment, please check updated comment

in this, I need to remove 'This is the Raju's first comment' up to here

Note: here name will not same every time user can mention any name but starting and ending letters will be same every time
please help me,

Thanks,
Dhilip
Hii..

create a user By using visualforce standard controller only
Hello,
I want to create automatic opportuinty line item when opportunity is created. How is this possible. I want to create of particular Product name suppose "Accomodation". I have written a code. 
trigger insertOppLineItem on Opportunity (after insert, after update) {
 system.debug('****************InTrigger**********************');
    
    if(trigger.isAfter && (trigger.isInsert || trigger.isUpdate)){
        String OpportunityID ;
        
    for(Opportunity o : Trigger.new){ 
        system.debug('OpportunityID 8 -->'+o.Id);
        OpportunityID = o.Id;
    
        if(OpportunityID  != null) 
        {
            List<Opportunity> opp = [select Id , No_of_Nights__c from Opportunity where ID =:  OpportunityID  ]; 
               system.debug('Opportunity 14.......... -->'+opp );

          //  List<OpportunityLineItem> vList = new List<OpportunityLineItem >();
           for(OpportunityLineItem v : trigger.new){
            o.No_of_Nights__c = v.Quantity;
        
                //vList.add(v);          
             }
               

        } 
        upsert v; 
    }   
}
}


How is this achivable?


Thanks &Regards,
Utkarsha
Hi Folks,

I am looking for the functionality where I can have the trigger which will auto populate the Opp Line Item if I select the specific line item.

For example If I add the "ABC" Line item to the Opportunity, trigger will auto populate the another line Item "XYZ" to the same Opp.

I have one rough draft of the trigger which is not working:

trigger AutoCreateProduct on Opportunity (after insert) { 
    List<OpportunityLineItem> OpportunityLineItems = new List<OpportunityLineItem>(); 
    for (Opportunity newOpportunity: Trigger.New) { 
        if(newOpportunityLineItem == 'ABC'){
            OpportunityLineItems.add(new OpportunityLineItem(OpportunityId = newOpportunity.Id,PricebookEntryId ='01un00000000000',Quantity = 1,UnitPrice = 0)); (This should be the another Line Item "XYZ")

Experts please help me.

Thanks,
James
            
  
Hi All,

I am working on one scenario where there are Multiple Child Records for eg:Account is a parent and Under Account multiple child Objects Records will be there.In that child Object i have created one checkbox field called Primary and first record should be primary and if users adding another record as primary it has to thrwo error Message there is already one primary Record please unselect the existing record and add new record as primary marked
Eg:Let say under account 3 child records are there and 1 is primary already and user is trying to add the 3 rd record as primary it should throw error Message
NEXT There are 3 Multiple Child Records and one is primary among them and user is trying to delete the primary record without marking any other records as primary then it should throw error Message as User is trying to Delete primary Record without making another primary
If there is only one primary and user is trying to delete then it should allow the user to delete.
Note :Child Record Refers to Contact 
Any one please guide me to help to implement this scenarios.
I have install the twilio package and following components.How to configure the two components.When customer send an sms it not created an case in sandbox.Here I am unable to receive sms details.The twilio message url where should I give in the salesforce.

User-added image
I am completely new about twilio configuration.Can someone please help.
Whenever customer send an sms then it create an case in sandbox automatically by using twilio api .

**Component 1: Visual force Fage**

    <apex:page controller="TwilioRequestControllerContacts" action="{!init}" showHeader="false" sidebar="false">
        <center>
            <apex:pageBlock title="Twilio Request Listener"></apex:pageBlock>         
        </center>
    </apex:page>
**Component 2: Controller**

    public with sharing class TwilioRequestControllerContacts
    {
        public String fromNumber      = ApexPages.currentPage().getParameters().get('From');
        public String toNumber        = ApexPages.currentPage().getParameters().get('To');
        public String body            = ApexPages.currentPage().getParameters().get('Body');
        public PageReference init()
        {
        try
        {          
           System.debug('STEP 0 FROM: ==========>' + fromNumber);
           System.debug('STEP 1 TO: ===============>' + toNumber);
           System.debug('STEP 2 BODY: ==========>' + body);
           System.debug('STEP 3  ==============>');                
           String account = 'xxxxxxxxxxx';  
           String token = 'xxxxxxxxxxxx';
           TwilioRestClient client = new TwilioRestClient(account,token);
           system.debug('STEP 4 test==3>'+client);
           if(fromNumber != null && toNumber != null) { 
        //my own logic               
          Case ca = new Case(Subject = fromNumber,Description = body,Origin = 'Phone');
               INSERT ca;      
               RETURN null;
           }
        }               
       catch(exception e){
            system.debug('STEP 7 error ==========>'+e);
       }
        RETURN null;
       } 
    }