• Hakim Upadhyay 45
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
I am new in the Salesforce coding. I have two pages. On one page I am filling the data and saving it. After click on Save button, I want to see the exact same data which I filled on last page. This is my code.
When I click on Save button first time, it stay on the same page. When I click on Save button again, it throws a message "The page you submitted was invalid for your session. Please refresh your page and try again

--------------------------------------FIRST VF PAGE-----------------------------------------
<apex:pageBlockSection title="Please fill the visitor information " collapsible="true">
  <apex:inputField value="{!visitor.Name}"/>  <br/>     
    <apex:pageMessages id="showmessage">
      </apex:pageMessages><br/>                     
        <apex:inputField value="{!visitor.CountryName__c}"/><br/>             
        <apex:inputField value="{!visitor.Passport_Number__c}"/><br/>           
        <apex:inputField value="{!visitor.Covid_19_Symtomp__c}"/><br/>
        <apex:inputField value="{!visitor.SendToQuarantineCenter__c}"/> <br/>           
        <apex:inputField value="{!visitor.CanVisitorGoToHome__c}"/><br/>
        <apex:inputField value="{!visitor.Quarantine_Cetner__c}"/><br/>
        <apex:inputField value="{!visitor.PatientEntryDate__c}"/><br/>
        <apex:inputField value="{!visitor.Patient_Exit_Date__c}"/><br/>
        </apex:pageBlockSection>        
                <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!saveV }" value="Save" reRender="true" />        
        </apex:pageBlockButtons>         
        </apex:pageBlock>
    </apex:form>    
--------------------------------Apex Code-----------------------------------
public class VisitorRegistration {   
       public Visitor__c visitor{get;set;}       
    public VisitorRegistration()
    {
        visitor= new Visitor__c();               
    }        
   public void getVisitorID()
{
Id id = apexpages.currentpage().getparameters().get('Id');
}    
 public PageReference saveV()
    {
        If(visitor.Name==null || visitor.Name=='')
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));
        }   
INSERT visitor;     
pagereference pr = new pagereference('/apex/VisitorRegistrationViewPage?id='+Visitor__c.id);  
        pr.setRedirect(false);
return pr;
    }
}

-------------------Second VF PAGE Where I want to See the Data
<apex:page controller="VisitorRegistration" showHeader="false" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Visitor Detail Page">
        
        <apex:pageBlockSection title="Visitor Information " collapsible="true">
             <apex:outputField value="{!visitor.Name}"/>  <br/>
            <apex:outputField value="{!visitor.CountryName__c}"/><br/>             
            <apex:outputField value="{!visitor.Passport_Number__c}"/><br/>           
            <apex:outputField value="{!visitor.Covid_19_Symtomp__c}"/><br/>
               <apex:outputField value="{!visitor.SendToQuarantineCenter__c}"/> <br/>           
            <apex:outputField value="{!visitor.CanVisitorGoToHome__c}"/><br/>
            <apex:outputField value="{!visitor.Quarantine_Cetner__c}"/><br/>
            <apex:outputField value="{!visitor.PatientEntryDate__c}"/><br/>
            <apex:outputField value="{!visitor.Patient_Exit_Date__c}"/><br/>
            </apex:pageBlockSection>
        </apex:pageBlock>    
         </apex:form>
</apex:page>


Please let me know , what is the mistake here. 
 
Hi All,

I am new in apex coding, I am trying to write trigger and this is my code.

My requirement is whenever I am creating new visitor record in the system( when I select multiselect picklist value which is 'Feve' and 'Dry Cough') new patient record should create under patient record.

My code is working fine, but patient record creates with ID, not name.

When I select only 1 value from the mutli-select picklist, then patient record creates with name.
trigger VisitorChangedIntoPatient on Visitor__c (after insert) {

    List<Patient__c> pat = new List<Patient__c>();
    
    for(Visitor__c visitor : Trigger.New)
    {
         Patient__c p = new Patient__c();
        
        if(trigger.isInsert && Visitor.Covid_19_Symtomp__c=='Fever' && Visitor.Covid_19_Symtomp__c=='DryCough')
        {
            p.id=visitor.id;
            p.Name=visitor.Name+'SQC';
            p.IsInfected__c=TRUE;
        }
        pat.add(p);
       
    }
    
    insert pat;
    
    
}
Hi All,

I am new in apex coding, I am trying to write trigger and this is my code.

My requirement is whenever I am creating new visitor record in the system( when I select multiselect picklist value which is 'Feve' and 'Dry Cough') new patient record should create under patient record.

My code is working fine, but patient record creates with ID, not name.

When I select only 1 value from the mutli-select picklist, then patient record creates with name.
trigger VisitorChangedIntoPatient on Visitor__c (after insert) {

    List<Patient__c> pat = new List<Patient__c>();
    
    for(Visitor__c visitor : Trigger.New)
    {
         Patient__c p = new Patient__c();
        
        if(trigger.isInsert && Visitor.Covid_19_Symtomp__c=='Fever' && Visitor.Covid_19_Symtomp__c=='DryCough')
        {
            p.id=visitor.id;
            p.Name=visitor.Name+'SQC';
            p.IsInfected__c=TRUE;
        }
        pat.add(p);
       
    }
    
    insert pat;
    
    
}
Hi All,

I am tring to authorize an org on visual studio code but when I am trying authorize it, I am getting the below error.

SFDX: Authorize an Org failed to run
Try this:
Kill the process running on port 1717 or use a custom connected app and update OauthLocalPort in the sfdx-project.json file.
19:31:13.241 sfdx force:auth:web:login --setalias VSCodePlayground --instanceurl https://login.salesforce.com --setdefaultusername ended with exit code 1

I have Killed the Process on port 1717 and tried it again then I am not getting any error but it is running for infinite time. 

Please help.

Thanks,
Parteek