• Felix Jong Seok Chae
  • NEWBIE
  • 60 Points
  • Member since 2017
  • Software Engineer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 41
    Replies
I created a new case with anonymous window and trigger succesfully set a field of a new case.
However, when I tried to create a new case (w/ same fields' values as one before) in test method, it does not update a field of this case via trigger.
I followed the help from the forum saying that I should fetch a case using soql after insertion, but it did not work.
Can someone please help me on this?
@isTest static void singleCaseInsertion() {
        Case newCase = new Case(...);
        insert newCase;
        test.startTest();
        Case newCasePtr = [Select casenumber, id, similarcases__c from case where id = :newCase.id];
        String newCaseSimCases = newCasePtr.similarCases__c;
        test.stopTest();
        System.assert(newCaseSimCases != null); // I get null value for this field, which is wrong.

    }

 
I have a static class variable called numRemain, which is initially set to some positive value and trigger decrements its value by 1 for each recursive call. Because my after-insert trigger has the part where each case in Trigger.New is updated, it fires Trigger in recursive manner. My queston is "after trigger is called more than once, is numRemain reset to its initial value or is numRemain decremented after each recursion?"
The reason why I ask this question is that I keep getting Apex Timeout error even though I have the conditional statement if(numRemain>0) in the beginning of the apex trigger.
Thank you. 
I am trying to write a test class and its methods in Apex.
I first created a case record in one of test methods and insert that case, but after I did test->New run for that method, I didn't see the new record was created in the salesforce case object.
Here is the apex code:
@isTest
public class MyTestClass {
    /**
     * Test for inserting a single case record
     */
    @isTest static void singleCaseInsertion() {
        Case newCase = new Case(
    		subject = 'abc', 
                type = 'def', 
    		description = 'testing.'
        );
	insert newCase;
    }
}

 
I have a custom field called similar_cases__c and would like to include formula fields of other case records in similar_cases_c of a new case.
I am sure I set the hyperlink of formula field correctly as I can click the casenumber and it directs me to the corresponding case record page.
So I want, for example, a similar_cases__c looks like "00771120, 00771121, 00771122" and I can click on these numbers to go to pages.
Type of similar_cases__c is text.

Thank you.
 
newCase.similarCases__c = '';
                        for (Case oldCase: collectedList) {
                            newCase.similarCases__c += oldCase.TestField__c;
                        }

User-added image
I am developing this in SFDC.
I have a custom field whose type is URL.
I noticed that if I do the following, I can set the url of the case record.
myCase.customField = 'xxx.salesforce.com/recordid_of_othercase/d'
I would like to create 5 links of 5 different recordids in this custom field instead of having just one link for one recordid.
Q1. Can I do this in one custom field in some way or should I create 5 custom fields and fill each field with recordid?
Q2. I heard that I can change the way the url looks, having caseNumber field instead of a long url. What is the exact format of the code for this?
Thank you.
I have a pointer to a case record and I can retrieve any field of that case.
I would like to create a url link of this record in the custom text-typed field of an another record so that
in the salesforce I can simply click the single button (case number for example) in that custom field,
and I will be directed to that case record. 
Thanks.
So I have rest api written in java and it can update a case record.
The problem is in the "after update" trigger, I don't know the command to get a update case record.
For "after insert" trigger, I knoew I can simply have "Case c = Trigger.New[0]" to get a new inserted case record.
Any help would be appreciated.
I have no problem fetching id of the new case just inserted.
I would like to get description value of that case with the following code, but I failed and received an exception.
 
//Make the request
      HttpResponse response = httpClient.execute(httpPost);

      //Process the results
      int statusCode = response.getStatusLine().getStatusCode();
      if (statusCode == 201) {
        String response_string = EntityUtils.toString(response.getEntity());
        JSONObject json = new JSONObject(response_string);
        // Store the retrieved lead id to use when we update the lead.
        caseId = json.getString("id");
        System.out.println("New case id from response: " + caseId);
        Description = json.getString("Description");
        System.out.println("New case description from response: " + Description);
      } else {
        System.out.println("Insertion unsuccessful. Status code returned is " + statusCode);
      }

 
I implemented a rest service in java and try to have a correct format of uri for query, insert, update, delete a case record from salesforce.
Is there a resource for this?
Thank you.
So far I created a custom text field that contains a case number of some case record on each line.
What I would like to do is to add a direct link next to each record's case number in that field.
Can somone help me out on this?
Thank you.
To create a list that has many links of other case records in a given case record, my plan is to create a custom field under the case object.
I'm developing this feature in apex developer console and I would first create a custome field in the salesforce. Does anyone know how to create a link to each case record in the field of the given case record?
I tried to implement the feature where one case object stores many case objects in its field and any case object can also have multiple case objects. I was trying to use following ways, each of which has some problem:

1. can't use related cases field because once a case's parent is set up, it can't be related to another case as each case can have at most one parent case.
2. can't use a junction object as I'm connecting two same type of case objects.

Is there any other way to achieve this feature?

Thank you
When I am using a single string for name field of casetags object, I can see a correct tag generated for a newly inserted case record. Now I have a list of string-typed tags and am trying to attach all those tags to a single new case record. Here are the examples that didn't work for multiple tags attachement.
ex1) name = "tag1, tag2"
ex2) for (String tag: tagsList) {
             name = tag;
             process each tag with httppost
        }
 
I would like to create a trigger where we can attach a tag to a new case record after a new record is inserted.
How do I do this in apex developer console?
I am trying to insert a new Case record in salesforce, so I created the REST in Java for that.
In both the APEX developer console and a inserting method in REST I use the field AccountID, but
in Salesforce website I have to choose string-typed name of a company for the field Account Name.
I also checked all possible fields for the case object in developer console and I didn't see AccountName field. However, when I used a specific ID (picked a random one from developer console) for AccountID in REST, the newly created case record acquired the Account Name associated with that Account ID. Is there a way to use Account Name direclty from REST instead of using AccountID?
I have a REST API in Java that tries to insert a new case record in SF.
HttpPost constructor takes URI string, which is formatted as baseUri + "/sobjects/case/".
I keep getting the message saying that insertion was unsuccessful. 
How can I find the correct URI to insert a new case record?
I collected a list of old cases relevant to a new case.
I saw 'related cases' under the cases tab and using apex trigger in the developer console,
I am trying to create links to those cases in the new case's related cases.
Can anyone know how to set this up?

 
In Java, we can easily create a list/set to collect strings in a text file with Scanner object.
What is the equivalent way of scanning a text file in Apex?
I wonder if there is an API in Salesforce Apex that can extract keywords from texts.
If not, does Apex allow a programmer to import any library like Java does? 
I have created a new account in the database, but 
query "select name from account" does not show this account in the developer console.
However, query "select name from account where name = 'nameOfNewRecord' " does show the correct result.
I used the second code snippet in: 
https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/apex_database/units/apex_database_soql

Thank you for your help in advance.
I created a new case with anonymous window and trigger succesfully set a field of a new case.
However, when I tried to create a new case (w/ same fields' values as one before) in test method, it does not update a field of this case via trigger.
I followed the help from the forum saying that I should fetch a case using soql after insertion, but it did not work.
Can someone please help me on this?
@isTest static void singleCaseInsertion() {
        Case newCase = new Case(...);
        insert newCase;
        test.startTest();
        Case newCasePtr = [Select casenumber, id, similarcases__c from case where id = :newCase.id];
        String newCaseSimCases = newCasePtr.similarCases__c;
        test.stopTest();
        System.assert(newCaseSimCases != null); // I get null value for this field, which is wrong.

    }

 
I have a static class variable called numRemain, which is initially set to some positive value and trigger decrements its value by 1 for each recursive call. Because my after-insert trigger has the part where each case in Trigger.New is updated, it fires Trigger in recursive manner. My queston is "after trigger is called more than once, is numRemain reset to its initial value or is numRemain decremented after each recursion?"
The reason why I ask this question is that I keep getting Apex Timeout error even though I have the conditional statement if(numRemain>0) in the beginning of the apex trigger.
Thank you. 
I am trying to write a test class and its methods in Apex.
I first created a case record in one of test methods and insert that case, but after I did test->New run for that method, I didn't see the new record was created in the salesforce case object.
Here is the apex code:
@isTest
public class MyTestClass {
    /**
     * Test for inserting a single case record
     */
    @isTest static void singleCaseInsertion() {
        Case newCase = new Case(
    		subject = 'abc', 
                type = 'def', 
    		description = 'testing.'
        );
	insert newCase;
    }
}

 
I have a custom field called similar_cases__c and would like to include formula fields of other case records in similar_cases_c of a new case.
I am sure I set the hyperlink of formula field correctly as I can click the casenumber and it directs me to the corresponding case record page.
So I want, for example, a similar_cases__c looks like "00771120, 00771121, 00771122" and I can click on these numbers to go to pages.
Type of similar_cases__c is text.

Thank you.
 
newCase.similarCases__c = '';
                        for (Case oldCase: collectedList) {
                            newCase.similarCases__c += oldCase.TestField__c;
                        }

User-added image
I am developing this in SFDC.
I have a custom field whose type is URL.
I noticed that if I do the following, I can set the url of the case record.
myCase.customField = 'xxx.salesforce.com/recordid_of_othercase/d'
I would like to create 5 links of 5 different recordids in this custom field instead of having just one link for one recordid.
Q1. Can I do this in one custom field in some way or should I create 5 custom fields and fill each field with recordid?
Q2. I heard that I can change the way the url looks, having caseNumber field instead of a long url. What is the exact format of the code for this?
Thank you.
I have a pointer to a case record and I can retrieve any field of that case.
I would like to create a url link of this record in the custom text-typed field of an another record so that
in the salesforce I can simply click the single button (case number for example) in that custom field,
and I will be directed to that case record. 
Thanks.
So I have rest api written in java and it can update a case record.
The problem is in the "after update" trigger, I don't know the command to get a update case record.
For "after insert" trigger, I knoew I can simply have "Case c = Trigger.New[0]" to get a new inserted case record.
Any help would be appreciated.