4

Any help with this issue is appreciated

I have two fields on ticket (Ticket status - is a picklist field) and (closing codes - is a picklist field). If ticket status is set to closed closing codes should be selected. this is the current fucntionality

Now they want reopen ticket functionality. So i have created a custom button (reopen ticket with reason) using javascripts and a visualforce page and used the VF page name in the custom button.

This is the Javascript for the button

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")} 

var update_Ticket = []; /* Declaring an array to pass the parameters */ 
var myTicket= new sforce.SObject("Ticket__c"); /* Declaring an object for the Ticket*/ 

myTicket.Id='{! Ticket__c.Id }'; /*setting the ID of the object to the Id of the current Ticket*/ 

myTicket.GLOBAL_IsReopenTicket__c = true; /* Setting the checkbox value as true */ 

update_Ticket.push(myTicket); /*pushing the updated object in queue*/ 
result_Update=sforce.connection.update(update_Ticket); /*updating the object*/ 

window.location= 'apex/ReopenTicketPage?id={! Ticket__c.Id }'; 

This is the VF page

<apex:form >
    <apex:pageBlock title="Reopen Ticket">
        <apex:pageMessages />
        <apex:pageBlockSection columns="1" >

           <apex:inputField value="{!Ticket__c.GLOBAL_Ticket_Status__c}"   />
           <apex:inputField value="{!Ticket__c.Reopen_Ticket__c}"  required="true"/>                    

        </apex:pageBlockSection>



        <apex:commandButton action="{!save}" value="Save" id="saveButton"/>
        <apex:commandButton action="{!cancel}" value="Cancel" id="cancelButton"/>
    </apex:pageBlock>
</apex:form>

Now the problem is when i am trying to click on reopen ticket with reason button which takes me to VF page and trying to save after selecting Reopen reason this is the error its throwing

Error:

Closing Code: Sorry but you can only set the closing code on a closed ticket. Please set the ticket status as closed in order to save a closing code.

The reason being. i cannot reopen the ticket with closing codes populated already. The only solution is for me to force set the closing code picklist field to None

Can anyone suggest me or guide me or send me a sample code how can i set this field to None when i click on Reopen ticket with reason button or set the closing code picklist field to None after i click on save button

1

This takes care of it, assuming the API name is Closing Codes. None is just a null value in the picklist.

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")} 

var update_Ticket = []; /* Declaring an array to pass the parameters */ 
var myTicket= new sforce.SObject("Ticket__c"); /* Declaring an object for the Ticket*/ 

myTicket.Id='{! Ticket__c.Id }'; /*setting the ID of the object to the Id of the current Ticket*/ 

myTicket.GLOBAL_IsReopenTicket__c = true; /* Setting the checkbox value as true */ 
// this line added vvv
myTicket.Closing_Codes__c = null; /* Set Closing Codes to None */

update_Ticket.push(myTicket); /*pushing the updated object in queue*/ 
result_Update=sforce.connection.update(update_Ticket); /*updating the object*/ 

window.location= 'apex/ReopenTicketPage?id={! Ticket__c.Id }'; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.