• srinivasasarmahere1.390217033575374E12
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies
The trigger looks at the Ticket__c(Custom Object) record whose status (GLOBAL_Ticket_Status__c == 'closed')  and updates case($Object) Status(Field) to closed
 
Ticket__c has a lookup to Case, so case can have multiple tickets associated to it but a ticket can only be associated to a case. 

Trigger Ticket on Ticket__c (after insert, after update) {
    Set<Id> closedTicketIds = new Set<Id>();
            for (Ticket__c ticket: Trigger.new) {
            if (ticket.GLOBAL_Ticket_Status__c == 'closed' && ) {
            closedTicketIds.add(ticket.id);
        } 
    }
    List<Ticket__c> ticketForClosing= [SELECT Id, GLOBAL_Goal__c FROM Ticket__c
                                         WHERE Id IN: closedTicketIds];

    set<Id> caseIDs = new set<Id>();
        for(Ticket__c t : ticketForClosing){
        caseIDs.add(t.GLOBAL_Goal__c);
    }
    List<Case> casesToUpdate = new List<Case>();
        for (Case c : [Select Id, Status From Case Where Id In : caseIDs]) {
        c.Status = 'closed';
        casesToUpdate.add(c);
    }
   
    update casesToUpdate;
}

1. The  issue is trigger does not look at all the records of ticket (Requirement is to look at all the records of ticket and only if the status(GLOBAL_Ticket_Status__c == 'closed') then go and close the Case) ,Currently trigger closes a case if either of the tickets sociated to the case are closed but not all.

2. Change the status on case 7 days after all the tickets associated to that case are closed(this allows the business to add tickets to the same case)


Can anyone please help me out on this

Thanks

Hello,

I have to write a batch apex class on two objects

1. Case 
2. Ticket__C

Ticket__c has a lookup to case and a case can have many ticket records but a ticket can only be associated to one case record

The Batch Apex class should run every morning at 2:00am and look at two fields(Status) in both the objects. Batch Apex shouls look at all the Cases and all the Tickets associated to the cases.

Case         -    Status (Field)
Ticket__c  -    GLOBAL_Ticket_Status__c (Field)

For example : if a case is associated with 3 Ticket__c records and the status of case is open, but status on 2 ticket__c records are closed and not the third record. Do not do anything.
If status of all the Ticket__c records are set to closed for a particular Case record but the Case record status itself is still open, Close the case after 7 days of Ticket__c records status closed. (This is because if business want to add a ticket to that particular case they can just because the case status is not closed).

Any help will be much appreciated


thank you
hi, 

I am writing a trigger 

There are tow Objects 
1. Case (standard $Object)
2. Ticket__C (Custom $Object) 

Ticket has a lookup to Case, and a Case can have multiple ticket_C records but a ticket__c can be allocated to one case only. 

The requirement is when all the tickets associated to the case are closed but the case status is not closed after 5 days of the ticket__c being closed. the trigger should change the status of the Case to closed. 


fields on the objects
Case  - Status (Field)
Ticket__C- GLOBAL_Ticket_Status__c (Field)

The trigger should look at all the records of a ticket__c associated to case and check for GLOBAL_Ticket_Status__c== 'Closed' . 
If the status of all records are closed and case status is not changed to close for 5 days then change the status of the Case to closed. 

This is what i came up with 

Trigger Ticket on Ticket__c (after insert, after update) {
    Set<Id> closedTicketIds = new Set<Id>();
     for (Ticket__c ticket: Trigger.new) {
        if (ticket.GLOBAL_Ticket_Status__c == 'closed') {
            closedTicketIds.add(ticket.id);
        }   
    }
    List<Case> ticketForClosing= [SELECT Status FROM Case
                                  WHERE Ticket__c IN: closedTicketIds];
    for (Case c: ticketForClosing) {
        c.Status = 'closed';
    }
    update ticketForClosing;
}


Compile Error: No such column 'Ticket__c' on entity 'Case'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 8 column 34

Any help is appreciated

Thanks
The requirement is when a role is creating a case lookup field should not be null

There is a sub role called as "Member_PA" under system Administrator role. and there are two roles Member and PA.

The requirement is if member enters a case validation rule should not fire but if a members PA enters a case validation rule on lookup test field should fire.

lookup field - REP_Customer_Representative__c (lookup to Account)

This is what i came up with but validation rule fires despite the roles.

AND( ISBLANK(REP_Customer_Representative__c),
$UserRole.Name <> "Member_PA" )

Any help is appreciated.

Thanks
Can anyone help me with writing a trigger on cross object field update.

Object: Booking__c                            Field: Booking_Type__c (is a picklist) one of the value is Cancelled

Object: Booking_Item__C                 Field: Booking_type__c (is also a picklist) one of the value is Cancelled

The requirement is,

when status (Booking_Type_c) of Booking_c is selected as cancelled  the status (Booking_Type__c ) of Booking_item__c should also be updated to cancelled.

Any help will be much appreciated.

Thank you
The requirement is when a role is creating a case lookup field should not be null

There is a sub role called as "Member_PA" under system Administrator role. and there are two roles Member and PA.

The requirement is if member enters a case validation rule should not fire but if a members PA enters a case validation rule on lookup test field should fire.

lookup field - REP_Customer_Representative__c (lookup to Account)

This is what i came up with but validation rule fires despite the roles.

AND( ISBLANK(REP_Customer_Representative__c),
$UserRole.Name <> "Member_PA" )

Any help is appreciated.

Thanks
The trigger looks at the Ticket__c(Custom Object) record whose status (GLOBAL_Ticket_Status__c == 'closed')  and updates case($Object) Status(Field) to closed
 
Ticket__c has a lookup to Case, so case can have multiple tickets associated to it but a ticket can only be associated to a case. 

Trigger Ticket on Ticket__c (after insert, after update) {
    Set<Id> closedTicketIds = new Set<Id>();
            for (Ticket__c ticket: Trigger.new) {
            if (ticket.GLOBAL_Ticket_Status__c == 'closed' && ) {
            closedTicketIds.add(ticket.id);
        } 
    }
    List<Ticket__c> ticketForClosing= [SELECT Id, GLOBAL_Goal__c FROM Ticket__c
                                         WHERE Id IN: closedTicketIds];

    set<Id> caseIDs = new set<Id>();
        for(Ticket__c t : ticketForClosing){
        caseIDs.add(t.GLOBAL_Goal__c);
    }
    List<Case> casesToUpdate = new List<Case>();
        for (Case c : [Select Id, Status From Case Where Id In : caseIDs]) {
        c.Status = 'closed';
        casesToUpdate.add(c);
    }
   
    update casesToUpdate;
}

1. The  issue is trigger does not look at all the records of ticket (Requirement is to look at all the records of ticket and only if the status(GLOBAL_Ticket_Status__c == 'closed') then go and close the Case) ,Currently trigger closes a case if either of the tickets sociated to the case are closed but not all.

2. Change the status on case 7 days after all the tickets associated to that case are closed(this allows the business to add tickets to the same case)


Can anyone please help me out on this

Thanks

Hello,

I have to write a batch apex class on two objects

1. Case 
2. Ticket__C

Ticket__c has a lookup to case and a case can have many ticket records but a ticket can only be associated to one case record

The Batch Apex class should run every morning at 2:00am and look at two fields(Status) in both the objects. Batch Apex shouls look at all the Cases and all the Tickets associated to the cases.

Case         -    Status (Field)
Ticket__c  -    GLOBAL_Ticket_Status__c (Field)

For example : if a case is associated with 3 Ticket__c records and the status of case is open, but status on 2 ticket__c records are closed and not the third record. Do not do anything.
If status of all the Ticket__c records are set to closed for a particular Case record but the Case record status itself is still open, Close the case after 7 days of Ticket__c records status closed. (This is because if business want to add a ticket to that particular case they can just because the case status is not closed).

Any help will be much appreciated


thank you
hi, 

I am writing a trigger 

There are tow Objects 
1. Case (standard $Object)
2. Ticket__C (Custom $Object) 

Ticket has a lookup to Case, and a Case can have multiple ticket_C records but a ticket__c can be allocated to one case only. 

The requirement is when all the tickets associated to the case are closed but the case status is not closed after 5 days of the ticket__c being closed. the trigger should change the status of the Case to closed. 


fields on the objects
Case  - Status (Field)
Ticket__C- GLOBAL_Ticket_Status__c (Field)

The trigger should look at all the records of a ticket__c associated to case and check for GLOBAL_Ticket_Status__c== 'Closed' . 
If the status of all records are closed and case status is not changed to close for 5 days then change the status of the Case to closed. 

This is what i came up with 

Trigger Ticket on Ticket__c (after insert, after update) {
    Set<Id> closedTicketIds = new Set<Id>();
     for (Ticket__c ticket: Trigger.new) {
        if (ticket.GLOBAL_Ticket_Status__c == 'closed') {
            closedTicketIds.add(ticket.id);
        }   
    }
    List<Case> ticketForClosing= [SELECT Status FROM Case
                                  WHERE Ticket__c IN: closedTicketIds];
    for (Case c: ticketForClosing) {
        c.Status = 'closed';
    }
    update ticketForClosing;
}


Compile Error: No such column 'Ticket__c' on entity 'Case'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 8 column 34

Any help is appreciated

Thanks