• Rupesh A 8
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Hi,

Scenario is, In Account object I have "Legal Entity" field, as we all know that there must be a relationship between Oppurtunity and Account objects.
So in Oppurtunity I have created one formula field like "Account Legal Entity" (formula is TEXT(Account.Legal_Entity__c)). Here I need to make this field as mandatory by using Validation rule. can anyone help me on this?
Thanks.
Hi,

I have one custom object, in that I have one date field like "Valid date" with date datatype. Here whenever I insert one new record into that that "Valid date" field should update date like today's date + 90 days.

How to acheive this, can anyone help me out?
Thanks.
Hi,

I have two custom objects like Private1 and Private2. For these two objects given lookup relationship to Account object. Here whatever the records are entered into these two objects then that particular Account team member can able to see the two custom object's records.

Actually, I have tried for one custom object and below is the code but I need the same scenario for multiple objects. Can anybody please help me on this.
And also I am new to salesforce inaddition to this, Can anybody help on test class for the above scenario?

Single Object record sharing (Private1):
global class PrivateSharingAccMember implements Database.Batchable<sObject> {
    static String emailAddress = 'rupesh@gmail.com';
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator([select Id, Account__c from Private1__c]);
    }
    
    global void execute(Database.BatchableContext BC, List<sObject> scope) {
        Map<ID, Private1__c> pvtMap = new Map<ID, Private1__c>((List<Private1__c>)scope);
        List<Private1__Share> newJobShrs = new List<Private1__Share>();
        
        List<Private1__Share> oldJobShrs = [select Id from Private1__Share WHERE ParentId IN :pvtMap.keySet() AND (RowCause = :Schema.Private1__Share.rowCause.Private_One__c)];
        
        for(Private1__c pvt : pvtMap.values()){
            Private1__Share pvtAccountShr = new Private1__Share();
            
            pvtAccountShr.ParentId = pvt.Id;
            pvtAccountShr.UserOrGroupId = pvt.Account__c;
            pvtAccountShr.AccessLevel = 'Read';
            pvtAccountShr.RowCause = Schema.Private1__Share.RowCause.Private_One__c;
            
            newJobShrs.add(pvtAccountShr);
        }
        
        }
    global void finish(Database.BatchableContext BC){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddress = new String[] {emailAddress};
        mail.setToAddresses(toAddress);
        mail.setSubject('Apex Sharing Records Completed');
        mail.setPlainTextBody('The Apex Sharing Records finished processing');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }

}

Please help me on this at your earliest convenience anyone.
Hi,

I have two custom objects like Private1 and Private2. For these two objects given lookup relationship to Account object. Here whatever the records are entered into these two objects then that particular Account team member can able to see the two custom object's records.

Please help me how to acheive this by using "Batch Apex". Thank you in advance.
Need a test class for the below Trigger.......

trigger AccountTrigger on Account (before insert) {
    for(Account acc:Trigger.new){
        if(acc.Rating=='Warm'){
            acc.AnnualRevenue = 20000;
        }
            else if(acc.Rating =='Hot'){
                acc.AnnualRevenue = 50000;
            
        }
        else if(acc.Rating == 'Cold'){
            acc.AnnualRevenue = 80000;
        }
    }
}

And also need a help on deployment....plz help me on this.......
Hi,

Scenario is, In Account object I have "Legal Entity" field, as we all know that there must be a relationship between Oppurtunity and Account objects.
So in Oppurtunity I have created one formula field like "Account Legal Entity" (formula is TEXT(Account.Legal_Entity__c)). Here I need to make this field as mandatory by using Validation rule. can anyone help me on this?
Thanks.
Hi,

I have one custom object, in that I have one date field like "Valid date" with date datatype. Here whenever I insert one new record into that that "Valid date" field should update date like today's date + 90 days.

How to acheive this, can anyone help me out?
Thanks.
Hi,

I have two custom objects like Private1 and Private2. For these two objects given lookup relationship to Account object. Here whatever the records are entered into these two objects then that particular Account team member can able to see the two custom object's records.

Actually, I have tried for one custom object and below is the code but I need the same scenario for multiple objects. Can anybody please help me on this.
And also I am new to salesforce inaddition to this, Can anybody help on test class for the above scenario?

Single Object record sharing (Private1):
global class PrivateSharingAccMember implements Database.Batchable<sObject> {
    static String emailAddress = 'rupesh@gmail.com';
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator([select Id, Account__c from Private1__c]);
    }
    
    global void execute(Database.BatchableContext BC, List<sObject> scope) {
        Map<ID, Private1__c> pvtMap = new Map<ID, Private1__c>((List<Private1__c>)scope);
        List<Private1__Share> newJobShrs = new List<Private1__Share>();
        
        List<Private1__Share> oldJobShrs = [select Id from Private1__Share WHERE ParentId IN :pvtMap.keySet() AND (RowCause = :Schema.Private1__Share.rowCause.Private_One__c)];
        
        for(Private1__c pvt : pvtMap.values()){
            Private1__Share pvtAccountShr = new Private1__Share();
            
            pvtAccountShr.ParentId = pvt.Id;
            pvtAccountShr.UserOrGroupId = pvt.Account__c;
            pvtAccountShr.AccessLevel = 'Read';
            pvtAccountShr.RowCause = Schema.Private1__Share.RowCause.Private_One__c;
            
            newJobShrs.add(pvtAccountShr);
        }
        
        }
    global void finish(Database.BatchableContext BC){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddress = new String[] {emailAddress};
        mail.setToAddresses(toAddress);
        mail.setSubject('Apex Sharing Records Completed');
        mail.setPlainTextBody('The Apex Sharing Records finished processing');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }

}

Please help me on this at your earliest convenience anyone.