• arag73877
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

not able to pass my case ID in apexdynamiccomponent tag  but the same in a normal visualforce page works javascript any help is highly appreciated

 

Part of my dynamic comp the pbtable displays  cases queried in the list

 

 

pageblocktable.var='a';

commandLink.onclick ='openNewTab({!a.Id})';

pageblocktable.add(commandlink);

 

 

 

MY JAVASCRIPT


function openNewTab(a){
alert('hi'+a);
}

Hi guys,

I have created a visualforce page in which i am using the apex dynamic component tag.I have a button called new and another button called cancel.On clicking the new button i am dynamically adding a tabusing the 

 

myTab.childComponents.add(NewButton);
 myTab.childComponents.add(cancelButton);

 

Finally (adding it to my tab panel)

NewCaseTab.childComponents.add(myTab);

 

The dynamic adding of tabs is working fine but I also  want to remove these tabs dynamically on clicking the cancel button.

Not able to find any solution for this online.Not sure if  this is possible.

 

any help or suggestions is highly appreciated.

 

Thanks and regards,

arag73877

What is purpose of Trigger factory and where can we use this?

I had tried with logic as below can any one help to correct the logic.

Code

 

List<Opportunity> opplist = [Select id from opportunity where StageName =:'Prospecting' and StageName =:'Closed Lost' Limit 2];

List<Task> listtask = [Select id,whatId from Task where Id IN :opplist.Id];

if(trigger.isupdate||trigger.isdelete){

if(Task task : Trigger.old)

 if(o.StageName == 'ClosedLost'){
            task.Status == 'Completed';
            listtask.add(task);
            }

      update listtask;

}

Hi, I am having one trigger " updatePhysicianTerritory". The trigger works fine in production without error. But in QA sandbox ,it showing error "

Apex script unhandled trigger exception by user/organization: 005E0000002r7g3/00Dc0000001JfAx Source organization: 00DE0000000e7EN (null)

updatePhysicianTerritory: System.LimitException: Too many SOQL queries: 101 "

 

This error doesnt come regularly.  But once or twice in a week, it will come. Below is the code for trigger. 

Any ideas on how to resolve it.

 

trigger updatePhysicianTerritory on Account (after update)
{

List<account> accPhysLst=new List<account>();

String bfreUpdateTerr{get;set;}
String aftrUpdateTerr {get;set;}
String newTerrOfAccount {get;set;}
List<Affiliation__c> lstAff = new List<Affiliation__c>();

List<String> phyIds = new List<String>();

try{


for(Account a:trigger.new) // For every Account that has been updated
{

Account beforeUpdate = System.Trigger.oldMap.get(a.Id);
bfreUpdateTerr = beforeUpdate.territory__c;
newTerrOfAccount=a.Territory__c;
if(bfreUpdateTerr!=newTerrOfAccount){
if(a.IsPersonAccount == false)
{ //Get all affliations related to the corresponding business account
for(Affiliation__c aff:[Select physician1__c,physician1__r.territory__c,hospital__c,Hospital__r.territory__c from Affiliation__c where hospital__c=:a.id])
{
if(aff.physician1__c!=null)
{
aftrUpdateTerr = aff.Hospital__r.territory__c;
phyIds.add(aff.physician1__c); // The list contains the physician ids of the corresponding affliation

}
}
}
}
}
if(phyIds!=null && phyIds.size()>0) // Find all the affliations of the physician
{
for(Account phys:[Select id,territory__c from Account where id IN:phyIds])
{
String territory ='';
for(Affiliation__c aff:[Select physician1__c,physician1__r.territory__c,hospital__c,Hospital__r.territory__c from Affiliation__c where physician1__c=:phys.id])
{
if(phys.id == aff.physician1__c)
{
if(territory!='' && territory!=null && aff.Hospital__r.territory__c!=null && !(territory.contains(aff.Hospital__r.territory__c)))
territory = territory+';'+aff.Hospital__r.territory__c;
else if(aff.Hospital__r.territory__c == null)
territory = territory;
else
{
if(phys.territory__c !=null && !(phys.territory__c.contains(aff.Hospital__r.territory__c)))
territory = aff.Hospital__r.territory__c;
else
territory = aff.Hospital__r.territory__c;

}
}
}
phys.territory__c = territory ;
accPhysLst.add(phys);

}
update accPhysLst;
}

}
catch(Exception e)
{
system.debug('Exception in person acc territory update'+e.getMessage());
}
}

 

So I got this trigger working (with the help of some nice members of this board!!!) but now, in production, I'm running into a System.LimitException error.  I believe my problem is with the section where I'm pulling all of the Task IDs into a set (starts at row 5).  However, I'm having trouble figuring out how to correct the problem.  After much googling and trolling on the boards, it seems like I need to create a map first (?) but I'm getting lost when I try to modify my code to do so.  

 

Thanks in advance for any help you can offer!!

 

trigger OppCloseDate on Opportunity (after update) {

Set<Id> oppIds = new Set<Id>();
Set<Id> taskIds = new Set<Id>();{
for(Task t:[select Id, WhatID from Task where Role_AM__c = 'TRUE']){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006')){
            taskids.add(t.WhatId);
for(Opportunity to:[select Id from Opportunity where Id in :taskIds]){
        oppIds.add(to.ID);
    }
    Set<Id> oppstoupdate = new Set<Id>();
    for(Integer i=0;i<trigger.new.size();i++){
        if(oppIds.contains(trigger.new[i].Id)){
            oppstoupdate.add(Trigger.new[i].id);

if(oppstoupdate.size() > 0){

   List<Opportunity> oList = [select Id, CloseDate from Opportunity where Id in :oppstoupdate];
    
   List<Task> taskstoupdate = new List<Task>();{
   for(Task tsk : [select Id, Opportunity_Close_Date__c from Task where WhatId in :oppstoupdate]){
   tsk.Opportunity_Close_Date__c = oList[0].CloseDate;
   taskstoupdate.add(tsk);
            }
        }
             if(!taskstoupdate.isEmpty()){
            update taskstoupdate;
        }
        }
        }
        }
        }
        }
        }
        }