• re_plagas
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 18
    Replies

Hi guys this is the trigger which is buggy.

 

 

trigger taskassign on Case (after insert) {

    for (Case c : trigger.new)
    {

       Event[] ownerinfo = [Select Id,OwnerId from Event where CreatedDate = today];
       //query the ownerid of event
       
       Case[] caseinfo = [Select Id,OwnerId from Case where CreatedDate = today AND Status = 'New'];
       
       for(Integer x=0; x <ownerinfo.Size();x++)
       {           
           Integer otheruser = [Select Count() from Event where OwnerId !=:ownerinfo[x].OwnerId AND CreatedDate = today];           
           //count the number of events created today & owned by the user
           
           Integer assigned = [Select Count() from Case where CreatedDate = today AND OwnerId =:ownerinfo[x].OwnerId AND Status = 'New'];
           //count the number of cases created today & owned by the user
         
           Integer notassigned = [Select Count() from Case where CreatedDate = today AND OwnerId !=:ownerinfo[x].OwnerId AND Status = 'New'] / otheruser;
           //count the number of cases created today & not owned by the user
          
           //Case[] updated = [Select OwnerId from Case Where CreatedDate = today AND Status = 'New' and LastModifiedById !=: caseinfo[x].OwnerId];
           
           
           
           for(Integer y=0; y <caseinfo.Size();y++)
           {
               if(caseinfo[y].OwnerId != ownerinfo[x].OwnerId)// if case ownerid is not = event ownerid
               {
                   if(assigned < notassigned)// if case owned by user less than cases owned by other ppl divided by their number
                   {   
                       
                       caseinfo[y].OwnerId = ownerinfo[x].OwnerId;  
                  
                   }
               
               }
              
             
           }
       
       }
     update caseinfo;
    }
}

 

This trigger fires whenever a case is created/cloned, thus getting the ownerid from Event and changed the newly created/cloned Case to the person in the Event. The issue here is that it update all records instead of the newly created/cloned Case.

 

Can you guys help out thanks!

Hi guys, I've created a link which enables the user to delete the specific stuff they want. In this case, it's Notes.

 

But when I click delete, I links me to a page which says:

 

The attempted delete was invalid for your session. Please confirm your delete.

 

What should I put in my codes to prevent this from happening?

 

<apex:page standardController="Handoff__c" showHeader="false" sidebar="false">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />   
    <style>
        .activeTab {background-color: #236FBD; color:white; background-image:none}
        .inactiveTab {background-color: lightgrey; color:black; background-image:none}
        .br {mso-data-placement:same-cell;}
    </style>
 </head>
    <apex:tabPanel switchType="client" selectedTab="tabNotes" id="CustomObjectTabPanel" tabClass="activeTab" inactivetabClass="inactiveTab">          
        <apex:tab label="Notes" name="Notes" id="tabNotes">           
            <apex:form >
                <apex:pageBlock title="Notes">
                    <apex:pageBlockTable value="{!Handoff__c.Notes}" var="note">
                       <apex:column value="{!note.body}" />
                        <apex:column HeaderValue="Edit"><a href="/{!LEFT(note.id,15)}/e?&retURL=%2Fapex%2FViewNA%3Fid%3D{!Handoff__c.Id}">Edit</a></apex:column>
                        
               
                        <apex:column HeaderValue="Del"><a href="/setup/own/deleteredirect.jsp?delID={!LEFT(note.id,15)}&_CONFIRMATIONTOKEN" onclick="return confirm('Are you sure you want to delete this note?')">Del</a></apex:column>
 
                    </apex:pageBlockTable>
                    <apex:commandbutton value="Add Notes" action="/002/e?parent_id={!LEFT(Handoff__c.Id,15)}&retURL=%2Fapex%2FViewNA%3Fid%3D{!Handoff__c.Id}"/>
                </apex:pageBlock>
            </apex:form>
        </apex:tab>
    </apex:tabPanel>
</apex:page>

Hi I need help on creating a trigger that fires email when I clone or create a record in a custom object.

Hi ppl, I need some sample codes to clone notes & attachment together with my records in the custom object.

 

Please help me out its urgent

Hi I'm tasked to have any emails sent to appear under Notes & Attachment. Currently I've setup such that it only appeared under the "Activity History" section.

 

Any idea I could post email to have it appear under Notes & Attachement?

Hi i wanted to clone my Notes & Attachment together when I clicked the main "Clone" button available at the details page of my custom object record.

 

But it seems that only my record is being cloned and not the related list. Was wondering if there is any ways to clone both the records as well as the Notes & Attachment to the new record.

 

E.g Record A, with Notes A,B & C

 

I wanna clone Record A together with Notes A,B,C

 

Please help out thx!

Hi I need to come up with a custom comments field that allow users to post comments. Ah and the comments can be expanable.

 

Anyone has any idea how to do it?

Hi guys, I've created a link which enables the user to delete the specific stuff they want. In this case, it's Notes.

 

But when I click delete, I links me to a page which says:

 

The attempted delete was invalid for your session. Please confirm your delete.

 

What should I put in my codes to prevent this from happening?

 

<apex:page standardController="Handoff__c" showHeader="false" sidebar="false">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />   
    <style>
        .activeTab {background-color: #236FBD; color:white; background-image:none}
        .inactiveTab {background-color: lightgrey; color:black; background-image:none}
        .br {mso-data-placement:same-cell;}
    </style>
 </head>
    <apex:tabPanel switchType="client" selectedTab="tabNotes" id="CustomObjectTabPanel" tabClass="activeTab" inactivetabClass="inactiveTab">          
        <apex:tab label="Notes" name="Notes" id="tabNotes">           
            <apex:form >
                <apex:pageBlock title="Notes">
                    <apex:pageBlockTable value="{!Handoff__c.Notes}" var="note">
                       <apex:column value="{!note.body}" />
                        <apex:column HeaderValue="Edit"><a href="/{!LEFT(note.id,15)}/e?&retURL=%2Fapex%2FViewNA%3Fid%3D{!Handoff__c.Id}">Edit</a></apex:column>
                        
               
                        <apex:column HeaderValue="Del"><a href="/setup/own/deleteredirect.jsp?delID={!LEFT(note.id,15)}&_CONFIRMATIONTOKEN" onclick="return confirm('Are you sure you want to delete this note?')">Del</a></apex:column>
 
                    </apex:pageBlockTable>
                    <apex:commandbutton value="Add Notes" action="/002/e?parent_id={!LEFT(Handoff__c.Id,15)}&retURL=%2Fapex%2FViewNA%3Fid%3D{!Handoff__c.Id}"/>
                </apex:pageBlock>
            </apex:form>
        </apex:tab>
    </apex:tabPanel>
</apex:page>

Hi I need help on creating a trigger that fires email when I clone or create a record in a custom object.

Hi ppl, I need some sample codes to clone notes & attachment together with my records in the custom object.

 

Please help me out its urgent

Hi I'm tasked to have any emails sent to appear under Notes & Attachment. Currently I've setup such that it only appeared under the "Activity History" section.

 

Any idea I could post email to have it appear under Notes & Attachement?

Hi i wanted to clone my Notes & Attachment together when I clicked the main "Clone" button available at the details page of my custom object record.

 

But it seems that only my record is being cloned and not the related list. Was wondering if there is any ways to clone both the records as well as the Notes & Attachment to the new record.

 

E.g Record A, with Notes A,B & C

 

I wanna clone Record A together with Notes A,B,C

 

Please help out thx!

Hi I need to come up with a custom comments field that allow users to post comments. Ah and the comments can be expanable.

 

Anyone has any idea how to do it?