• Natsu
  • NEWBIE
  • 100 Points
  • Member since 2017
  • Consulant

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 11
    Replies
Hello, 
I want to identify all cases that have the 'Case Origin' field set to 'email'. I then want to update these records with a new  'Case Origin' value of 'Phone'. Can you please explain how I would go about doing this? It would be helpful if you can write out the code as well. Thanks! 
Hey, 

I've got a custom object called Deposit__c that is related to Case and Account. Each Deposit must have a Case, and an Account. Due to rules in place outside of salesforce, I know this will always be the case. I'm having issues getting things ironed out so I'm hoping someone can see where I've gone wrong...
 
trigger DepositTrigger on Deposit__c (before insert) {
	Set<String> AcctNums = new Set<String>();
    for(Deposit__c d : Trigger.New){
        AcctNums.add(d.SBR_ID__c);
    }
    List<Case> caseList = [select id from Case where RecordTypeId = '0121a0000001nWh' and LastModifiedDate < LAST_N_DAYS:30 and case.Account.Name in :AcctNums];
    Map<String,Id> accountCaseIdMap = new Map<String,Id>();
    for(Case c : caseList){
        accountCaseIdMap.put(c.Account.Name,c.Id);
    }
    for(Deposit__c d2: Trigger.new){
        if(case.Id != accountCaseIdMap.get(d2.Id)){
            Case newCase = new Case(Account = d2.Account.Name, RecordTypeId = '0121a0000001nWh');
            caseList.add(newCase);
        }
    }
    upsert caseList;
    for(Case c : caseList){
        accountCaseIdMap.put(c.SBR_ID__c,c.Id);
    }
    for(Deposit__c d3 : Trigger.New){
        Case depCase = accountCaseIdMap.get(d3.SBR_ID__c);
        d3.CaseId = depCase;
    }
    update accountCaseIdMap.values;
}
It is possible that within the same file, multiple deposit__c records will be for the same account. It is also possible that some deposit__c records will not have cases open, while others will. If there is an open case(or a recently closed one) i want to relate the new deposit__c record to the existing case and not create a new one. 

My current issue is that on line 13 I have an Invalid foreign key relationship: Deposit__c.Account. I have no idea why this is happening. Any thoughts?

Thanks in advance. 



 
can anyone please give the code example how to query two unrelated object in one apex class and conditionally populate a field in the 3rd object using the fetched data ?
I mean how to use 3 object in one apex class(fetching data from 2 object and and mapping the fetched information to 3rd object fields).
All object are unrelated.
Please help
Hi,

I'm doing the below trail to create a scratch org using the procedures and getting the below error:
ERROR:  A fatal signup error occurred. Please try again. If you still see this error, contact Salesforce Support for assistance. sfdx-project.json.

Any help would be appriciated.

https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/create-and-test-our-scratch-org

project-scratch-def:
{
    "orgName": "Dreamhouse",
    "edition": "Developer",
    "hasSampleData": "false",
    "settings": {
      "orgPreferenceSettings": {
        "s1DesktopEnabled": true,
        "selfSetPasswordInApi": true,
        "s1EncryptedStoragePref2": false
      }
    }
}

sfdx-project.json:
{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true,
            "package": "dreamhouse",
            "versionNumber": "3.0.0.NEXT",
            "versionName": "Winter '19"
        }
    ],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "44.0",
    "packageAliases": {
        "dreamhouse": "0Ho1I000000XZDVSA4",
        "dreamhouse@2.0.0-4": "04t1I0000036seVQAQ",
        "dreamhouse@3.0.0-5": "04t1I0000036u98QAA"
    }
}

User-added image

 
  • January 15, 2019
  • Like
  • 1
Hi,

I'm doing the below trail to create a scratch org using the procedures and getting the below error:
ERROR:  A fatal signup error occurred. Please try again. If you still see this error, contact Salesforce Support for assistance. sfdx-project.json.

Any help would be appriciated.

https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/create-and-test-our-scratch-org

project-scratch-def:
{
    "orgName": "Dreamhouse",
    "edition": "Developer",
    "hasSampleData": "false",
    "settings": {
      "orgPreferenceSettings": {
        "s1DesktopEnabled": true,
        "selfSetPasswordInApi": true,
        "s1EncryptedStoragePref2": false
      }
    }
}

sfdx-project.json:
{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true,
            "package": "dreamhouse",
            "versionNumber": "3.0.0.NEXT",
            "versionName": "Winter '19"
        }
    ],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "44.0",
    "packageAliases": {
        "dreamhouse": "0Ho1I000000XZDVSA4",
        "dreamhouse@2.0.0-4": "04t1I0000036seVQAQ",
        "dreamhouse@3.0.0-5": "04t1I0000036u98QAA"
    }
}

User-added image

 
  • January 15, 2019
  • Like
  • 1
So I'm learning apex via http://www.sfdc99.com/ 

Now he simple states, get a free dev org, i did that and then go through steps xyz to connect mavensmate...problem is mavensmate is no longer supported. 

So i installed all the packages need for visual studio code, but for the love of all things holy i cannot figure out how to connect it. Also whenever i log into my free dev org i'm not sure if im in sandbox or in the dev org, there's literally nothing different (other than one has less content).

I also have a corporate account, obviously i cant use the firms enterprise edition...
Suppose we have two users A and B, A is above B's role hierarchyB is having access to Object C, but A doesn't.
B has created many records of Object C.
Will A be able to see those records of B?
When the System Administrator logs in as a different user and creates a record the activity history shows that the logged in user created the record, not the admin. How is it possible to know who really created the record?
 
HI 
In my vf page i am displating all account records (by using  <apex:pageBlockTable> ) it is done  here my problem is 
when i am click on account name ( any one from displayed account names) then immediately display one popup in that popup should display that account name  record details 
 
 
Hello, 
I want to identify all cases that have the 'Case Origin' field set to 'email'. I then want to update these records with a new  'Case Origin' value of 'Phone'. Can you please explain how I would go about doing this? It would be helpful if you can write out the code as well. Thanks! 
Anyone know the code for this?

Write a class with a method that updates all of an accounts contacts, setting contact field called “active to false”
Hey, 

I've got a custom object called Deposit__c that is related to Case and Account. Each Deposit must have a Case, and an Account. Due to rules in place outside of salesforce, I know this will always be the case. I'm having issues getting things ironed out so I'm hoping someone can see where I've gone wrong...
 
trigger DepositTrigger on Deposit__c (before insert) {
	Set<String> AcctNums = new Set<String>();
    for(Deposit__c d : Trigger.New){
        AcctNums.add(d.SBR_ID__c);
    }
    List<Case> caseList = [select id from Case where RecordTypeId = '0121a0000001nWh' and LastModifiedDate < LAST_N_DAYS:30 and case.Account.Name in :AcctNums];
    Map<String,Id> accountCaseIdMap = new Map<String,Id>();
    for(Case c : caseList){
        accountCaseIdMap.put(c.Account.Name,c.Id);
    }
    for(Deposit__c d2: Trigger.new){
        if(case.Id != accountCaseIdMap.get(d2.Id)){
            Case newCase = new Case(Account = d2.Account.Name, RecordTypeId = '0121a0000001nWh');
            caseList.add(newCase);
        }
    }
    upsert caseList;
    for(Case c : caseList){
        accountCaseIdMap.put(c.SBR_ID__c,c.Id);
    }
    for(Deposit__c d3 : Trigger.New){
        Case depCase = accountCaseIdMap.get(d3.SBR_ID__c);
        d3.CaseId = depCase;
    }
    update accountCaseIdMap.values;
}
It is possible that within the same file, multiple deposit__c records will be for the same account. It is also possible that some deposit__c records will not have cases open, while others will. If there is an open case(or a recently closed one) i want to relate the new deposit__c record to the existing case and not create a new one. 

My current issue is that on line 13 I have an Invalid foreign key relationship: Deposit__c.Account. I have no idea why this is happening. Any thoughts?

Thanks in advance. 



 
can anyone please give the code example how to query two unrelated object in one apex class and conditionally populate a field in the 3rd object using the fetched data ?
I mean how to use 3 object in one apex class(fetching data from 2 object and and mapping the fetched information to 3rd object fields).
All object are unrelated.
Please help
In custom "Save and New" button  I've to fetch the same parent from Lookup in every record when we click the save & new button.
How can we achive this ? Please reply ASAP
User-added image

Like in this pic every new record same Account should be selected when we select for the first record!! 


Anyone Please reply ASAP.
It will be very helpful for us.

 
  • July 11, 2017
  • Like
  • 0