• ashish kumar 18
  • NEWBIE
  • 5 Points
  • Member since 2014

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

What is the maximum numbers of users which can share the same generic user name and password to login at the same time?
HI All,

I need SFDC salescloud latest dump.

Send me at :    main.hu.9a@gmail.com
HI All,

I need SFDC salescloud latest dump.

Send me at :    main.hu.9a@gmail.com

Thanks
Ashish
I am getting an error
System.Exception: Too many SOQL queries: 101


I have the followiing trigger which I am attempting to change to avoid that error message. 

I have tried using a keyset with this but it has not worked out yet. The tricky part is that I am updating an opportunity from a task, and there are also triggers on opportunities.

trigger UpdateLatestDueDatefromTask on Task (after insert, after update) {


try{
    //the trigger will update the opportunity's latest_open_due_date__c field
    for (task ta : trigger.new){
        id Opportunityid = ta.WhatId;
        
        Opportunity oOpportunity = [select id, Latest_Open_Due_Date__c from Opportunity where id = :Opportunityid LIMIT 1];
        if (oOpportunity.Latest_Open_Due_Date__c <  ta.ActivityDate ) {
        	if (ta.Status != 'Completed' ) {
        		System.debug ('in completed');
        		oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
            	//update oOpportunity;
        	}
        }
        
        if (oOpportunity.Latest_Open_Due_Date__c == null) {
        	if (ta.Status != 'Completed'  ) {
        		oOpportunity.Latest_Open_Due_Date__c = ta.ActivityDate;
            	//update oOpportunity;
        	}
        }
        
       List <Task> ActiveTask = [select id, WhatId from Task where Whatid = :Opportunityid and status != 'Completed'];
          
        	if (ActiveTask.isEmpty()){
        	 	oOpportunity.Latest_Open_Due_Date__c = null;
             	///update oOpportunity;
        	}
    	update oOpportunity;
    }
}
catch (Exception e ){
            System.debug('Create trigger exception ' + e.getMessage());
            
      }
 }


THIS IS AMONG THE THINGS I HAVE BEEN TRYING:

trigger UpdateLatestDueDatefromTask on Task (after insert, after update) {

  //the trigger will update the opportunity's latest_open_due_date__c field
    for (task ta : trigger.new){
	try{    	
     List<Opportunity> updateOpportunities = new list<Opportunity>();
     
     List <Tasks> OpportunitiesWithTasks = [select id, ActivityDate, WhatId, (Select id, Latest_Open_due_Date__c from Opportunity) from Task 
     	Where Id in :Trigger.newMap.keySet()];
     for (Opportunity oOpportunity: [select id, WhatId, ActivityDate from Opportunity where id in :Trigger.NewMap.keySet()] ) {
			list <Opportunity> parentOpp = [select id, Latest_Open_Due_Date__c From Opportunity where id in :Trigger.NewMap.get (oTask.WhatId)];
			if (parentOpp.Latest_Open_Due_Date__c < oTask.WhatId) {
				parentOpp.Latest_Open_Due_Date__c = oTask.ActivityDate;
				
			}
    }
}

(The error I get is that it doesn't understand the relationship for opportunity.)

THANKS!


I need to have a user assigned in order to make this test class actually function. My actual class and trigger work as designed, but the test class fails because it requires a user to be present in order to work. Here is the code I have. I'm very new to apex and coding all together so I'm kinda stuck. 

@isTest
public with sharing class UpdateNCMOwnerHandlerTest
{
public static testMethod void testUpdateNCMOwnerHandler()
{
  List<Non_Conforming_Material__c> nonConformingMaterials = new List<Non_Conforming_Material__c>();
Non_Conforming_Material__c nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'In Process'); //#1
  nonConformingMaterials.add(nonConformingMaterial);
  nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'Resolution'); //#2
  nonConformingMaterials.add(nonConformingMaterial);
  insert nonConformingMaterials;
    }
}