• Calin Constantin Bostan
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi,

I am struggling with the great object "Ideas". We are using 2 zones (zone A & zone B). And I want to create a validation rule that restricts users based on profile name to be able to post Ideas on both zones.
And if possible another validation rule - the owner of the idea and the system admin to be the only ones that can edit and delete an idea.
Bellow you can find all the fields that we are using in the Object.
Thank You,
User-added image
Hi all,

I am new in Salesforce and I need a bit of help.
We customize a field in a Dev Sandbox, we made it to show the total amount of the opportunities attached to an vehicle. And also created a triger that updates that value every time a value in the opportunty is changed. But now we need to move all of that to a different sandbox.
Can you please help me with how can we do that.
What tool can I use to do that?

Thank You,
Calin B.

 
Hi All,

I have a request from our business, to create a field on a custom object called Vehicle, A field that show the total values of the opportunities associated with the specific vehicle. Our in-house developer managed to do that, but with a schedule rule that runs only once/day, and the request is to show the total amount every time an amount in a opportunity is updated.

The developer created 2 different classes, one to make a sum of all values from all opportunities:
/* @date 29.09.2017 */
/* @description for update a summary field on vehicle level, which sums up the opportunity amount of the related opportunities*/
global class Opportunity_Amount_Update implements Database.Batchable<sObject>  {

    global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator('SELECT ID FROM Vehicle__c ' );
    }
    
    global decimal STTO = 0;

    global void execute(Database.BatchableContext bc, List<Vehicle__c> scope){
        // process each batch of records
        Set<Vehicle__c> Veh = new Set<Vehicle__c>();
        List<Vehicle__c> Veh1 = new List<Vehicle__c>();
        List<Opportunity> OPP = [Select Id, GH_Vehicle__c, Amount from Opportunity WHERE GH_Vehicle__c <>'']; 
          for (Vehicle__c VEx : scope) {    
            for (Opportunity Opps1 : OPP ) {
                 if(Opps1.GH_Vehicle__c == VEx.id) {
                     STTO = STTO + Opps1.Amount;
                 }
            }
            VEx.Opportunity_amount__c = STTO;
            Veh.add(VEx);
            STTO = 0;
         }
        Veh1.addall(Veh);
        update Veh1;
    }    

    global void finish(Database.BatchableContext bc){
    }    
}

And another one as a scheduler:
global class Opportunity_Amount_Update_scheduler implements Schedulable {
    global void execute(SchedulableContext ctx) {
        Opportunity_Amount_Update OA = new Opportunity_Amount_Update();
        DataBase.executeBatch(OA);
    }
}

Ans as I mentionated abowe, we need the first class (Opportunity_Amount_Update) to run every time the value of an opportunity changes.
Can you please help me with this, if it can be made like that?

Thank You
Calin B

HI,

I need ur help !!

I am getting error INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id:[] Trigger.ShareOperatingUnits:  when test code covereag.

 

Test class ::

private class TestNewWorkOrder {

    static testMethod void myUnitTest() {
        User usr1 = [select id, Name, ProfileId  from User where Profile.Name = 'System Administrator' limit 1 ];
        System.runAs(usr1) {  
        Object__c ou = new Object__c();
        ou.Branch_Manager__c = UserInfo.getUserId();
        ou.Name = 'Test';
        insert ou;
     }

}

 

After insert Trigger::

trigger ShareOperatingUnits on Object__c (after insert, after update) {
    List<Object__Share> ouShareList = new List<Object__Share>();

    for(Object__c ou: Trigger.New) {
        Object__Share ouShare = new Object__Share();
        ouShare.ParentId  = ou.Id;
        ouShare.UserOrGroupId = ou.Branch_Manager__c;
        ouShare.AccessLevel = 'Read';
        ouShareList.add(ouShare);
        allOUids.add(ou.id);
    }

   insert ouShareList;   // HERE I M GETTING ERROR

}

 

Please tell me what i done wrong .

I think i need to make some changes on object side my trigger is working fine but getting prblm for test coverage .

Please help me !!

 

Many Thnks In Advance

 

Piyush