• Qihao Guo
  • NEWBIE
  • 40 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
User-added imageWhen I authorize an org and use customer url to login I got this error ad the localhost is 1717. Also I have already set up my proxy into my environment variable. So Anyone knows how to solve this error.
trigger addCase on Account (After update) {
   List<Account> allAccounts = new List<Account>([Select id,(select id from cases where status in('New','Open')) from account where id in :Trigger.new]);
   List<Case> newCases = new List<Case>();
    
    for(Account myAccount :allAccounts){
    
        if(myAccount.cases !=null){
            Case c = new Case();
            c.Accountid = myAccount.Id;
            c.Type = 'ICM';
            c.Origin = 'WEB';
            c.Status = 'New';
            newCases.add(c); 
            System.debug('create successfully');
        }
 
        
    }
    if(!newCases.isEmpty()){
        insert newCases;
        System.debug('create successfully');
    }
 
}
Here is my code to create a new case. If I want to debug, what code should I put in execute anonymous windows?
import requests
import urllib3
from simple_salesforce import Salesforce
urllib3.disable_warnings()

sf = Salesforce( username='username', password = 'password', security_token='RjWJloN2hZi0V4vyA5ruSQs5')
access_token = sf.session_id
url = 'https://bell7-dev-ed.develop.my.salesforce.com/services/data/v55.0/sobjects/Case'
parms = {
    "Status": "New",
    "Origin": "Web",
    "Subject": "Test case",
    "Priority": "Medium",
    "Description": "TO Test whether I can post the Case",
}
auth ={'Authorization' : 'Bearer ' + access_token, 'Content-type' : 'application/json'}
res = requests.post(url, headers = auth, params = parms)
print(res.text)


this is my python code, which I want to create a new case in salesforce, but it will give me "message":"The HTTP entity body is required, but this request has no entity body.","errorCode":"JSON_PARSER_ERROR"
so which part I made wrong?
I just want to know if I want to create a new case by using apex, how can I develop?
trigger addCase on Account (After update) {
   List<Account> allAccounts = new List<Account>([Select id,Fuzion_Status__c,(select id from cases where status in('New','Open')) from account where id in :Trigger.new]);
   List<Case> newCases = new List<Case>();
    
    for(Account myAccount :allAccounts){
    Account oldAccount = trigger.oldMap.get(myAccount.id);
    if(oldAccount.Fuzion_Status__c == 'Initial Phone call' && myAccount.Fuzion_Status__c != 'Initial Phone call'){
        if(myAccount.cases !=null){
            Case c = new Case();
            c.Accountid = myAccount.Id;
            c.Type = 'ICM';
            c.Origin = 'WEB';
            c.Division__c = 'Case Management';
            c.Status = 'New';
            c.RecordTypeId = '01236000000OJLq';
            newCases.add(c); 
        }
     }
        
    }
    if(!NewCases.isEmpty()){
        insert newCases;
    }
 
}
This is my code to create a case and I have just create an object called fuzion status but why it still shows variable does not exist?User-added imageUser-added image
trigger caseCheck on Account (After update) {
   List<Account> allAccounts = new List<Account>([Select id,Fuzion_Status__c,(select id from cases where status in('New','Open')) from account where id in :Trigger.new]);
   List<Case> newCases = new List<Case>();
    
    for(Account myAccount :allAccounts){
    Account oldAccount = trigger.oldMap.get(myAccount.id);
    if(oldAccount.Fuzion_Status__c == 'Initial Phone call' && myAccount.Fuzion_Status__c != 'Initial Phone call'){
        if(myAccount.cases !=null){
            Case c = new Case();
            c.Accountid = myAccount.Id;
            c.Type = 'ICM';
            c.Origin = 'WEB';
            c.Division__c = 'Case Management';
            c.Status = 'New';
            c.RecordTypeId = '01236000000OJLq';
            newCases.add(c); 
        }
     }
        
    }
    if(!NewCases.isEmpty()){
        insert newCases;
    }
 
}
This is my code about create a new case, but it shows the problems in the following pictureUser-added image
Hi, It is my first time to use apex and I want to know if I want to use apex to create a case how should I do that?
Hi, It is my first time to use apex and I want to know if I want to use apex to create a case how should I do that?