• Arjun y 7
  • NEWBIE
  • 55 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 32
    Replies
Hi All,

Could any one tell me how to sort the below list of strings?

Input : List<String> strList = new List<String>{'1_4','1_2','1_8','2_3'};

Output Should display as : 1_2,1_4,1_8,2_3

Thanks
Arjun

 
Hi All,

I have a requirement to send emails to the account owner whenever a post is created in their feed.

I wrote the below code to insert feeditem. If i add createdbyid field in post, i am unable to get the emails.

If i comment the createdbyid, then i am able to recieve the emails. 
FeedItem post = new FeedItem();
post.ParentId = '0F9c0000000DLT6CAO'; 
post.createdById = '005a000000BA2zjAAD';
post.Body = 'Happy Anniversary, Sean!';
insert post;
Can anyone please let me know how can i achieve this?

Thank You
Arjun
Hi All,

My requirement is to add radio button to each row to select input values in vf page. User should enter only one input field at a time.

For the below image, i need to add radio button for each page block section. In that, i will allow users to select the input value based on the radio button. User should select only one input field at one time.Can any one help me how to solve this?





User-added image
Hi All,

I am unable to pass the values from VF page to controller for date field.
 
<apex:page docType="html-5.0" controller="Sample">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection>
            <apex:pageBlockSectionItem>
                Date: <apex:input type="date" value="{!dat}"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex Controller:

public class Sample {
    public Date dat {get;set;}
    public Sample() {
           System.debug('EnteringDate'+dat);
    }
}

 
Hi All,

I am unable to combine the list of values into single string.

Below code gives output as:

Csvfilebody'29682
','92367
','72661
','14768
','15031
','1158'

I need output as:
Endpoint: Csvfilebody'29682','92367','72661','14768','15031','1158'
String uploadCsv = csvFileBody.toString().trim();
System.debug('Csvfilebody'+uploadCsv);
//uploadCsv:Csvfilebody29682
92367
72661
14768
15031
1158
 List<String> uploadCSVlist = new List<String>();
uploadCSVlist = uploadCsv.split('\n');
List<String> csvFieldNames = new List<String>();
 csvFieldNames = uploadCSVlist[0].split(',');
List<String> sme = new List<String>();
string allstring;
for(integer i=1;i<uploadCsvList.size();i++)
{
 allString = allString+','+'\''+uploadCSVlist[i]+'\'';
  }

 
Hi All,

I have a string which contains in the below format. I want only FailureList value. Can you please let me know how to get the failure list value from string?
 
String s1 = 'd:[FailureList=null, RecordTypeIDMap={Customer=012j0XXXX}]'

 
Hi All,

I need to return the values from apex class to batch class. The below code throws constructor not defined. Can any one let me know how to pass list of inserted accounts to batch class.
 
public with sharing class CalloutBatchApex implements Database.Batchable<Integer>, Database.AllowCallouts {
    public Iterable<String> start(Database.BatchableContext BC) {
        return new List<Integer> { 1, 2, 3 };
    }
 
    public void execute(Database.BatchableContext info, List<integer> iteration) {
        // Make the callout to the web service and import the records to Salesforce for the iteration.
       String responseStrng = response.getBody();
        insertAccountMethod.methodone(responseStrng);
    }
 
    public void finish(Database.BatchableContext info) {}
}

//Calling Apex class here

public class insertAccountMethod{
   List<Account> accList = new List<Account>();
         public methodone(String responseStrng){
         //my code here
         I need to return the above accList to batch class.I have tried with the below line
          
         CalloutBatchApex c = new CalloutBatchApex();
         DataBase.execute(c,1);

        }
}

Thanks
​Arjun
Hi All,

I need to return the values from apex class to batch class. The below code throws constructor not defined. Can any one let me know how to pass list of inserted accounts to batch class.
 
public with sharing class CalloutBatchApex implements Database.Batchable<Integer>, Database.AllowCallouts {
    public Iterable<String> start(Database.BatchableContext BC) {
        return new List<Integer> { 1, 2, 3 };
    }
 
    public void execute(Database.BatchableContext info, List<integer> iteration) {
        // Make the callout to the web service and import the records to Salesforce for the iteration.
       String responseStrng = response.getBody();
        insertAccountMethod.methodone(responseStrng);
    }
 
    public void finish(Database.BatchableContext info) {}
}

//Calling Apex class here

public class insertAccountMethod{
   List<Account> accList = new List<Account>();
         public methodone(String responseStrng){
         //my code here
         I need to return the above accList to batch class.I have tried with the below line
          
         CalloutBatchApex c = new CalloutBatchApex();
         DataBase.execute(c,1);

        }
}

 
Hi All,

I have a requirement to populate the active contact record id in Account object. For this, i have taken a contact lookup in account object. whenever user updates the active field, i have written a trigger to update the contact lookup field in account.

If any user deactivates the contact, then the contact lookup in account object should become empty. I am not able to fulfill this scenario.

Can any one please help me for this requirement.

Code:
 
trigger sample on contact(after insert,after update){
List<Account> accList = new List<Account>();
        List<Account> accUpdateContactPerson = new List<Account>();
        List<Id> contactIdList = new List<Id>();
        Map<Id,Id> ContactAccountIdMap = new Map<Id,Id>();
        accUpdateContactPerson.clear();
        for(Contact con:cont){
            
            if(con.Active__C == true){
                contactIdList.add(con.Id);
                ContactAccountIdMap.put(con.AccountId,con.Id);
            }
            
        }
        accList = [select Id,Contact__c from Account where Id IN: ContactAccountIdMap.keySet()];

            for(Account acc:accList){
                if(contactAccountIdMap.get(acc.Id)!=null){
                    acc.Contact__c = contactAccountIdMap.get(acc.Id);
                }
                else{
                    acc.Contact__c = null; 
                }
                accUpdateContactPerson.add(acc);
            }
            update accUpdateContactPerson;
}

 
Hi All,

My requirement is i have a "Description" field which contains 90chars. I need to store the first 45 chars in one formula field and next 45 chars in another formula field.

I tried with one i.e Formulafield1: TRIM(LEFT( Description , 45)). It is working fine.

Can i know any solution for the second formula field to display next 45 chars.

Thanks
 
Hi All,

My requirement is to send attachments to external system.

Can any one help me on this requirement? 
Hi All,

I need to insert a rich text area field's image in documents/attachments in a custom object.

Can anyone guide me how to insert a rich text area image record in custom object?

Thanks
Arjun
Hi All,

I have developed one small rest api service. External system is calling daily to that service.

My query is how can i check that callout time in salesforce when ever they are calling myservice from external system?
 
@RestResource(urlMapping='/myservice')
global class MyService {
    @HttpGet
    global static String doGet() {
        String name = RestContext.request.params.get('name');
        return 'Hello '+name;
    }

 
Hi All,

I am recieving heap size limit for the below code. I want to send 25000 records as csv via email. 
 
List<Account > acclist = [Select id,name , CreatedDate , lastModifiedDate from Account];
string header = 'Record Id, Name , Created Date, Modified Date \n';
string finalstr = header ;
for(Account a: acclist)
{
 /* Here I am getting heap size limit error*/     
 string recordString = a.id+','+a.Name+','+a.CreatedDate+','+a.LastModifiedDate +'\n';
       finalstr = finalstr +recordString;
}
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'Account.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'pravinl059@gmail.com'};
String subject ='Account CSV';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('Account CSV ');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

 
Hi,

I have a list contains 27000 records. I need to send these records as an attachment via email. 

While i am running the class, receiving heapsize limit error. I can able to send attachment for 5000 records not for above 20000 records.

Can any one please help me to sort out this.

Thanks
Hi All,

Can you please help me how to hit 20 times third party server from salesforce.

My requirement is third party server contains 20000 records. I need to fetch those 20000 records into salesforce and then need to update those 20000 records in salesforce.

We have a third party url which pulls the 1000 records per one transaction. In this manner, we need to hit 20 times to fetch all records. 

Can any one provide me the best approach for this requirement. 
Hi All,

Requirement is we need to do update operation in salesforce from SAP. The job should runs every day.

In SAP, we have 30000 records. When we hit the SAP server, we have to receive entire 30000 records in one call using REST Api. I tried this and am getting this error "System.StringException: String length exceeds maximum: 6000000" Can i know is there any other approach to work on?
Hi All,

Our scenario is, we need to deserialize the below JSON structure using Rest API in salesforce.
String JSONString = 
"[{
"Accounts":  
{
"score":  
 
{
"bghu": "1"
"ghdf": "/Date(14-5-2012)/"
"erty": "hjuyt"
"jgfhd": "30"
"poiu": " 0.00"
"nbvc": " 0.00"
"vjdt": " 200000.00"
"ghgh": " 200000.00"
"jkkj": " 100000.00-"
}
}
}]"

Rest Class

Map<String, object> root = (Map<String, object>)JSON.deserializeUntyped(jsonString);
I am receiving the value after deserializing the jsonstring
root = {d={results=({erty=ZTRD, ghgh=200000.00, vjdt=200000.00, bghu=1, poiu=0.00, jgfhd=30, nbvc=0.00, ghdf=/Date(1459123200000)/, jkkj=100000.00-})}}

Now i want results in a list in below format
List<Object> items = (List<Object>)root.get('results'); But while i am doing this, receiving result as null.


Can any one help me on this
Hi All,

I need to include quotes into the below url. can anyone please help me to solve this.

String i = 'https://test.dev.com?id='1234'';

I need to send that in endpoint url as request.setendpoint(i). While i am doing in this process, single quotes are ,missing in endpoint url.

Thanks

 
Hi All,

I need to create a formula field for the below scenario. I tried many ways to get the formula field.

Type Field contains two values. Those are
1.ASD8765
2.OPDQ76YTH

If Type field begins with 'A', the formula field should store the first 4 characters of the string as Formula field ='ASD8'
If Type field begins with 'O', the formual field should store the first 3 charaters of the string as Fomula field = 'OPD'

Can any one help me to solve this.

Thank You!!
Arjun
Hi All,

I have a requirement to populate the active contact record id in Account object. For this, i have taken a contact lookup in account object. whenever user updates the active field, i have written a trigger to update the contact lookup field in account.

If any user deactivates the contact, then the contact lookup in account object should become empty. I am not able to fulfill this scenario.

Can any one please help me for this requirement.

Code:
 
trigger sample on contact(after insert,after update){
List<Account> accList = new List<Account>();
        List<Account> accUpdateContactPerson = new List<Account>();
        List<Id> contactIdList = new List<Id>();
        Map<Id,Id> ContactAccountIdMap = new Map<Id,Id>();
        accUpdateContactPerson.clear();
        for(Contact con:cont){
            
            if(con.Active__C == true){
                contactIdList.add(con.Id);
                ContactAccountIdMap.put(con.AccountId,con.Id);
            }
            
        }
        accList = [select Id,Contact__c from Account where Id IN: ContactAccountIdMap.keySet()];

            for(Account acc:accList){
                if(contactAccountIdMap.get(acc.Id)!=null){
                    acc.Contact__c = contactAccountIdMap.get(acc.Id);
                }
                else{
                    acc.Contact__c = null; 
                }
                accUpdateContactPerson.add(acc);
            }
            update accUpdateContactPerson;
}

 
Hi All,

My requirement is i have a "Description" field which contains 90chars. I need to store the first 45 chars in one formula field and next 45 chars in another formula field.

I tried with one i.e Formulafield1: TRIM(LEFT( Description , 45)). It is working fine.

Can i know any solution for the second formula field to display next 45 chars.

Thanks
 
Hi All,

I have a requirement to send emails to the account owner whenever a post is created in their feed.

I wrote the below code to insert feeditem. If i add createdbyid field in post, i am unable to get the emails.

If i comment the createdbyid, then i am able to recieve the emails. 
FeedItem post = new FeedItem();
post.ParentId = '0F9c0000000DLT6CAO'; 
post.createdById = '005a000000BA2zjAAD';
post.Body = 'Happy Anniversary, Sean!';
insert post;
Can anyone please let me know how can i achieve this?

Thank You
Arjun
Hi All,

I am unable to pass the values from VF page to controller for date field.
 
<apex:page docType="html-5.0" controller="Sample">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection>
            <apex:pageBlockSectionItem>
                Date: <apex:input type="date" value="{!dat}"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex Controller:

public class Sample {
    public Date dat {get;set;}
    public Sample() {
           System.debug('EnteringDate'+dat);
    }
}

 
Hi All,

I am unable to combine the list of values into single string.

Below code gives output as:

Csvfilebody'29682
','92367
','72661
','14768
','15031
','1158'

I need output as:
Endpoint: Csvfilebody'29682','92367','72661','14768','15031','1158'
String uploadCsv = csvFileBody.toString().trim();
System.debug('Csvfilebody'+uploadCsv);
//uploadCsv:Csvfilebody29682
92367
72661
14768
15031
1158
 List<String> uploadCSVlist = new List<String>();
uploadCSVlist = uploadCsv.split('\n');
List<String> csvFieldNames = new List<String>();
 csvFieldNames = uploadCSVlist[0].split(',');
List<String> sme = new List<String>();
string allstring;
for(integer i=1;i<uploadCsvList.size();i++)
{
 allString = allString+','+'\''+uploadCSVlist[i]+'\'';
  }

 
Hi All,

I need to return the values from apex class to batch class. The below code throws constructor not defined. Can any one let me know how to pass list of inserted accounts to batch class.
 
public with sharing class CalloutBatchApex implements Database.Batchable<Integer>, Database.AllowCallouts {
    public Iterable<String> start(Database.BatchableContext BC) {
        return new List<Integer> { 1, 2, 3 };
    }
 
    public void execute(Database.BatchableContext info, List<integer> iteration) {
        // Make the callout to the web service and import the records to Salesforce for the iteration.
       String responseStrng = response.getBody();
        insertAccountMethod.methodone(responseStrng);
    }
 
    public void finish(Database.BatchableContext info) {}
}

//Calling Apex class here

public class insertAccountMethod{
   List<Account> accList = new List<Account>();
         public methodone(String responseStrng){
         //my code here
         I need to return the above accList to batch class.I have tried with the below line
          
         CalloutBatchApex c = new CalloutBatchApex();
         DataBase.execute(c,1);

        }
}

Thanks
​Arjun
Hi All,

I have a requirement to populate the active contact record id in Account object. For this, i have taken a contact lookup in account object. whenever user updates the active field, i have written a trigger to update the contact lookup field in account.

If any user deactivates the contact, then the contact lookup in account object should become empty. I am not able to fulfill this scenario.

Can any one please help me for this requirement.

Code:
 
trigger sample on contact(after insert,after update){
List<Account> accList = new List<Account>();
        List<Account> accUpdateContactPerson = new List<Account>();
        List<Id> contactIdList = new List<Id>();
        Map<Id,Id> ContactAccountIdMap = new Map<Id,Id>();
        accUpdateContactPerson.clear();
        for(Contact con:cont){
            
            if(con.Active__C == true){
                contactIdList.add(con.Id);
                ContactAccountIdMap.put(con.AccountId,con.Id);
            }
            
        }
        accList = [select Id,Contact__c from Account where Id IN: ContactAccountIdMap.keySet()];

            for(Account acc:accList){
                if(contactAccountIdMap.get(acc.Id)!=null){
                    acc.Contact__c = contactAccountIdMap.get(acc.Id);
                }
                else{
                    acc.Contact__c = null; 
                }
                accUpdateContactPerson.add(acc);
            }
            update accUpdateContactPerson;
}

 
Hi All,

My requirement is i have a "Description" field which contains 90chars. I need to store the first 45 chars in one formula field and next 45 chars in another formula field.

I tried with one i.e Formulafield1: TRIM(LEFT( Description , 45)). It is working fine.

Can i know any solution for the second formula field to display next 45 chars.

Thanks
 
Hi All,

I am recieving heap size limit for the below code. I want to send 25000 records as csv via email. 
 
List<Account > acclist = [Select id,name , CreatedDate , lastModifiedDate from Account];
string header = 'Record Id, Name , Created Date, Modified Date \n';
string finalstr = header ;
for(Account a: acclist)
{
 /* Here I am getting heap size limit error*/     
 string recordString = a.id+','+a.Name+','+a.CreatedDate+','+a.LastModifiedDate +'\n';
       finalstr = finalstr +recordString;
}
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'Account.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {'pravinl059@gmail.com'};
String subject ='Account CSV';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('Account CSV ');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

 
Hi All,

Can you please help me how to hit 20 times third party server from salesforce.

My requirement is third party server contains 20000 records. I need to fetch those 20000 records into salesforce and then need to update those 20000 records in salesforce.

We have a third party url which pulls the 1000 records per one transaction. In this manner, we need to hit 20 times to fetch all records. 

Can any one provide me the best approach for this requirement. 
Hi All,

Requirement is we need to do update operation in salesforce from SAP. The job should runs every day.

In SAP, we have 30000 records. When we hit the SAP server, we have to receive entire 30000 records in one call using REST Api. I tried this and am getting this error "System.StringException: String length exceeds maximum: 6000000" Can i know is there any other approach to work on?
Hi All,

Our scenario is, we need to deserialize the below JSON structure using Rest API in salesforce.
String JSONString = 
"[{
"Accounts":  
{
"score":  
 
{
"bghu": "1"
"ghdf": "/Date(14-5-2012)/"
"erty": "hjuyt"
"jgfhd": "30"
"poiu": " 0.00"
"nbvc": " 0.00"
"vjdt": " 200000.00"
"ghgh": " 200000.00"
"jkkj": " 100000.00-"
}
}
}]"

Rest Class

Map<String, object> root = (Map<String, object>)JSON.deserializeUntyped(jsonString);
I am receiving the value after deserializing the jsonstring
root = {d={results=({erty=ZTRD, ghgh=200000.00, vjdt=200000.00, bghu=1, poiu=0.00, jgfhd=30, nbvc=0.00, ghdf=/Date(1459123200000)/, jkkj=100000.00-})}}

Now i want results in a list in below format
List<Object> items = (List<Object>)root.get('results'); But while i am doing this, receiving result as null.


Can any one help me on this
Hi All,

I need to create a formula field for the below scenario. I tried many ways to get the formula field.

Type Field contains two values. Those are
1.ASD8765
2.OPDQ76YTH

If Type field begins with 'A', the formula field should store the first 4 characters of the string as Formula field ='ASD8'
If Type field begins with 'O', the formual field should store the first 3 charaters of the string as Fomula field = 'OPD'

Can any one help me to solve this.

Thank You!!
Arjun