+ Start a Discussion
Kumar GKumar G 

URL No Longer Exists Error while Clicking on Submit Button.

public void saveAndSubmit()
    {
        List<CaseComment> lstCmt = new List<CaseComment>();
        CaseComment cmt = new CaseComment();
        List<Technician_Appointment_Scheduler__c> lstTAS = new List<Technician_Appointment_Scheduler__c>();
        Boolean success = false;
        String strOli='';
        try{                    
            if(lstSelectedProviProduct!=null && lstSelectedProviProduct.size()>0)
            {
                for(SelectionWrapper wrapper : lstSelectedProviProduct)
                {                  
                  
                    strOli += getSemiColonValid(wrapper.RecordId);
                    system.debug('--->>>'+strOli);
                }
            }
            troubleTicket.Selected_Order_Line_Items__c=strOli;

            if(SelectedMultiSite == false){
                troubleTicket.Service_Zip_Code__c = this.selectedAccount.Service_Location_Postal_Code__c;
                system.debug('===>>>Service_Zip_Code__c '+troubleTicket.Service_Zip_Code__c);
            }
            else{
                for(Account acc: lstServiceAddress){
                    if(acc.id == SelectedServiceAddress){
                        troubleTicket.Service_Zip_Code__c = acc.Service_Location_Postal_Code__c;
                        break;
                    }
                }
            }           
            List<Case> ttList = new List<Case>{troubleTicket};
            List<Database.saveResult> srList = Database.insert(ttList);
            for (Integer i=0;i<srList.size();i++) {
                Database.SaveResult sr = srList.get(i);
                Case relatedCase = new Case();
                if(sr.isSuccess()){
                    relatedCase = ttList.get(i);
                    cmt = new CaseComment();
                    cmt.ParentId = relatedCase.id;
                    cmt.CommentBody = relatedCase.Description;
                    lstCmt.add(cmt);
                    if(relatedCase.Status_Type__c=='Dispatched Out'){
                        tas.Trouble_Ticket__c = relatedCase.id;
                        lstTAS.add(tas);
                    }
                }
            }
            if(lstCmt.size()>0 && lstCmt!=null){
                insert lstCmt;
            }
            if(lstTAS.size()>0 && lstTAS!=null){
                insert lstTAS;
            }
        }
        catch(Exception e)
        {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(msg);
            system.debug(e.getMessage());
        }
    }

When i clicked on Submit button this will call one method called saveandsubmit , plz refer the method code in code sample.

Please help me to resolve this issue . Thanks in advance.
Swaraj Behera 7Swaraj Behera 7
Hi,

Please Use below link if you are using Inline VF page.Can you please post your VF page and Class.
http://help.salesforce.com/HTViewSolution?id=000230608&language=en_US

Thanks
Kumar GKumar G
Hi Swaraj,

Thanks for your reply.please find the VF Page code in code sample.
<apex:page controller="TestController"  sidebar="false" action="{!onloadReview}">
<script>
    var buttonClicked = false;
    var evt = window.attachEvent || window.addEventListener;
    var checkEvt = window.attachEvent ? 'onbeforeunload' : 'beforeunload';
    evt(checkEvt, function(e) {
    
        if (!buttonClicked)
        {
            var msg = 'You have not yet Submit or Cancel the Trouble Ticket.';
            (e || window.event).returnValue = msg;
            return msg;
        }
    });

    function avoidPopUp(input)
    {
        buttonClicked = true;
        if(input.id.indexOf('ttSubmit')>0 || input.id.indexOf('ttSave') >0)
        {
         input.disabled='disabled';
        }
    }
</script>
    <apex:form id="frm">
        <c:TroubleTicketWizard activeEle="step5" recId="test" RetUrl="/test"></c:TroubleTicketWizard>
        <apex:pageMessages id="pgMsg"></apex:pageMessages>
        <apex:pageBlock id="pb1">
            <apex:pageBlockSection columns="4" >
            <apex:pageBlockSectionItem dataStyle="width:17%;" labelStyle="width:13%;">
                <apex:outputLabel value="Account" for="name"></apex:outputLabel>
                <apex:outputText id="name" value="{!selectedAccount.Name}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="width:17%;" labelStyle="width:13%;" rendered="{!!SelectedMultiSite}">
                <apex:outputLabel value="Service Address" for="name"></apex:outputLabel>
                <apex:outputText id="address" value="{!serviceAddress}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="width:20%;" labelStyle="width:13%;" rendered="{!SelectedMultiSite}">
                <apex:outputLabel value="Service Address" for="name"></apex:outputLabel>
                <apex:outputText id="address" value="{!showServiceAddress}"/>
            </apex:pageBlockSectionItem>
           <apex:pageBlockSectionItem dataStyle="width:17%;" labelStyle="width:13%;">
                <apex:outputLabel value="Service " for="selectedCurrentService"></apex:outputLabel>
                <apex:repeat value="{!lstSelectedServices}" var="service"> <t/>
                    <apex:outputPanel >
                        <apex:outputText id="ser" value="{!service.displayLabel}"/>
                        {!IF(service_index_map[service.displayLabel] == lastindexofService,'',',')}
                    </apex:outputPanel>
                </apex:repeat>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="width:17%;" labelStyle="width:13%;">
                <apex:outputLabel value="{!$ObjectType.Case.Fields.ContactId.Label}" for="ContactId"></apex:outputLabel>
                <apex:outputField id="ContactId" value="{!troubleTicket.ContactId}"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        </apex:pageBlock> 
        <apex:pageBlock >
        <apex:pageBlockSection >
            
            <apex:pageBlockSectionItem dataStyle="width:17%;" labelStyle="width:13%;">
                <apex:outputLabel value="Product(s) Selected" for="name"></apex:outputLabel>
                <apex:repeat value="{!lstSelectedProviProduct}" var="product">
                    <apex:outputPanel >
                        <apex:outputText id="address" value="{!product.EmailId}"/>
                        {!IF(ServiceProduct_index_map[product.displayLabel] == lastindexofServiceProduct,'',',')}
                    </apex:outputPanel>
                </apex:repeat>
            </apex:pageBlockSectionItem> 
            
        </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock mode="inlineEdit" >
            <apex:pageBlockSection title="Case Information" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Select_a_Template__c.Label}" for="template"></apex:outputLabel>
                    <apex:outputField id="template" value="{!troubleTicket.Select_a_Template__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Status.Label}" for="Status"></apex:outputLabel>
                    <apex:outputField id="Status" value="{!troubleTicket.Status}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
               </apex:pageBlockSectionItem>                
               <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Status_Type__c.Label}" for="statusType"></apex:outputLabel>
                   <apex:outputField id="statusType" value="{!troubleTicket.Status_Type__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField> 
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Priority__c.Label}" for="Priority"></apex:outputLabel>
                    <apex:outputField id="Priority" value="{!troubleTicket.Priority__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Severity__c.Label}" for="Severity"></apex:outputLabel>
                    <apex:outputField id="Severity" value="{!troubleTicket.Severity__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                 </apex:pageBlockSectionItem> 
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Escalation_Method__c.Label}" for="escalationMethod"></apex:outputLabel>
                    <apex:outputField id="escalationMethod" value="{!troubleTicket.Escalation_Method__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Estimated_Time_To_Restore__c.Label}" for="estimatedTime"></apex:outputLabel>
                     <apex:outputField id="estimatedTime" value="{!troubleTicket.Estimated_Time_To_Restore__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Trouble_Initiation_Mode__c.Label}" for="initiationMode"></apex:outputLabel>
                    <apex:outputField id="initiationMode" value="{!troubleTicket.Trouble_Initiation_Mode__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Trouble_Type__c.Label}" for="troubletype"></apex:outputLabel>
                    <apex:outputField id="troubletype" value="{!troubleTicket.Trouble_Type__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Ticket_Type__c.Label}" for="ticketType"></apex:outputLabel>
                    <apex:outputField id="ticketType" value="{!troubleTicket.Ticket_Type__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>       
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Cause_Code__c.Label}" for="CauseCode"></apex:outputLabel>
                     <apex:outputField id="CauseCode" value="{!troubleTicket.Cause_Code__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Close_Comment__c.Label}" for="CloseComment"></apex:outputLabel>
                     <apex:outputField id="CloseComment" value="{!troubleTicket.Close_Comment__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Next_customer_Update_Interval__c.Label}" for="nextCustomerUpdate"></apex:outputLabel>
                     <apex:outputField id="nextCustomerUpdate" value="{!troubleTicket.Next_customer_Update_Interval__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Intrusive_Testing_Auth_Indicator__c.Label}" for="intrusiveTesting"></apex:outputLabel>
                    <apex:outputField id="intrusiveTesting" value="{!troubleTicket.Intrusive_Testing_Auth_Indicator__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Deferred_Until_Date__c.Label}" for="deferredUntilDate"></apex:outputLabel>
                    <apex:outputField id="deferredUntilDate" value="{!troubleTicket.Deferred_Until_Date__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
               </apex:pageBlockSectionItem>     
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.DuplicateTicket_Allowed__c.Label}" for="ticketAllowed"></apex:outputLabel>
                    <apex:outputField id="ticketAllowed" value="{!troubleTicket.DuplicateTicket_Allowed__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
               </apex:pageBlockSectionItem>           
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Responsible_Organization__c.Label}" for="responsibleOrganization"></apex:outputLabel>
                    <apex:outputField id="responsibleOrganization" value="{!troubleTicket.Responsible_Organization__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
               </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Case.Fields.Administrative_Organization__c.Label}" for="adminstrativeOrg"></apex:outputLabel>
                    <apex:outputField id="adminstrativeOrg" value="{!troubleTicket.Administrative_Organization__c}">
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
               </apex:pageBlockSectionItem>
               <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Tech Notes" for="description"></apex:outputLabel>
                    <apex:outputField id="description" value="{!troubleTicket.Description}"> 
                            <apex:inlineEditSupport event="ondblClick" /> 
                    </apex:outputField>
                </apex:pageBlockSectionItem>                              
                </apex:pageBlockSection>
            </apex:pageBlock>
            <apex:pageBlock > 
            <apex:pageBlockSection title="Technician Appointment Scheduler Information">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Appointment Id"></apex:outputLabel>
                    <apex:outputField value="{!tas.Appointment_Id__c}"></apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Appointment Number"></apex:outputLabel>
                    <apex:outputField value="{!tas.Appointment_Number__c}"></apex:outputField>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Appointment Date"></apex:outputLabel>
                    <apex:outputField value="{!tas.Appointment_Date__c}"></apex:outputField>
                </apex:pageBlockSectionItem> 
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Time Slot"></apex:outputLabel>
                    <apex:outputField value="{!tas.Time_Slot__c}"></apex:outputField>
                </apex:pageBlockSectionItem> 
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Location"></apex:outputLabel>
                    <apex:outputField value="{!tas.Location__c}"></apex:outputField>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
           
            <apex:pageBlockSection columns="4" >
            <apex:pageBlockSectionItem dataStyle="text-align: right; width: 20%">
               <apex:commandButton id="ttBack" value="Back" action="{!backToTicketDetail}" onclick="avoidPopUp(this);"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="text-align: center; width: 20%">
               <apex:commandButton id="ttSave" value="Hold" action="{!saveTicket}" onclick="avoidPopUp(this);"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="text-align: center; width: 20%">
               <apex:commandButton id="ttSubmit" value="Submit" action="{!saveAndSubmit}" onComplete="submitTOM8()" onclick="avoidPopUp(this);"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem dataStyle="text-align: left; width: 20%">
                 <apex:commandButton id="accCancel" value="Cancel" action="{!Cancel}"  immediate="true" onclick="avoidPopUp(this);"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:actionFunction name="submitTOM8" action="{!submitTroubleTicket}"/>
    </apex:form>
</apex:page>

 
Swaraj Behera 7Swaraj Behera 7
Hi Kumar,
In the action function oncomplete you are calling another method.Can you provide the code for that method named 'submitTroubleTicket'.
<apex:commandButton id="ttSubmit" value="Submit" action="{!saveAndSubmit}" onComplete="submitTOM8()" onclick="avoidPopUp(this);"/>

 <apex:actionFunction name="submitTOM8" action="{!submitTroubleTicket}"/>

Thanks
Kumar GKumar G
Hi Swaraj, Please find the submitTroubleTicket method code below : public PageReference submitTroubleTicket(){ try{ system.debug('===>>>in submitTroubleTicket'); Case2TroubleTicketHandler.createTicketRequest(troubleTicket.Id, 'New'); } catch(Exception e){ ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()); ApexPages.addMessage(msg); system.debug(e.getMessage()); } return new PageReference('/'+troubleTicket.Id); }
Swaraj Behera 7Swaraj Behera 7
Hi Kumar,
Can you change the submitTroubleTicket method with below code.
public PageReference submitTroubleTicket()
{ 
	try
	{ 
		system.debug('===>>>in submitTroubleTicket'); 
		Case2TroubleTicketHandler.createTicketRequest(troubleTicket.Id, 'New');


			 } 
	catch(Exception e)
		{ 
			ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()); 
			ApexPages.addMessage(msg); system.debug(e.getMessage()); 
		} 

		PageReference newPage = New PageReference('/'+troubleTicket.Id);
      	newPage.setRedirect(true);

		return newPage;


	}

Let me know if you find any issue.
Thanks,
Swaraj
Kumar GKumar G

Hi Swaraj,

I checked with the below code Still "URL No Longer Exists Error" is coming , any other solution Plz share.
 
public PageReference submitTroubleTicket(){
        try{
            system.debug('===>>>in submitTroubleTicket');
            Case2TroubleTicketHandler.createTicketRequest(troubleTicket.Id, 'New');
        }
        catch(Exception e){
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(msg);
            system.debug(e.getMessage());
        }
                   PageReference newPage = New PageReference('/'+troubleTicket.Id);
                        newPage.setRedirect(true);
                   return newPage; 
       }

 
Kumar GKumar G
Hi Swaraj, I checked with the below code Still "URL No Longer Exists Error" is coming , any other solution Plz share. public PageReference submitTroubleTicket(){ try{ system.debug('===>>>in submitTroubleTicket'); Case2TroubleTicketHandler.createTicketRequest(troubleTicket.Id, 'New'); } catch(Exception e){ ApexPages.Message msg = new ApexPages.Message(ApexPages. Severity.ERROR,e.getMessage()); ApexPages.addMessage(msg); system.debug(e.getMessage()); } PageReference newPage = New PageReference('/'+ troubleTicket.Id); newPage.setRedirect(true); return newPage; }