• Amit Roy
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
i have a vf  page
<apex:page sidebar="false" showHeader="false" controller="definition_overview_controller" tabstyle="Label__c" id="page">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
<script>
function setFocusOnLoad() {}
$(document).ready(function(){
 $(".fieldInput").focusin(function() {
 var tempObj = $(this).closest('td').prev('td').find('input').val();
 if(tempObj.length >0){       
  sleep(100).then(()=>{
   sforce.connection.sessionId='{!GETSESSIONID()}';
   var tempList = sforce.apex.execute("ListofLabel","getAllLabels",{Objname:tempObj});
   $(".fieldInput").autocomplete({source: tempList});              
    });   
   }
});  
});

function sleep (time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}       
</script>
<apex:sectionHeader title="Mapping Object" subtitle="Form" id="header"/>
<apex:form id="form">
<apex:pageBlock id="pageblock" >
 <apex:pageBlockTable title="Related List" value="{!label}" var="l" id="pageblocktable"> 
  <apex:column headerValue="Lebal Name" id="col1" >
      <apex:outputText value="{!l.name}">
     
       <apex:param value="{!l.name}" AssignTo="{!levelName}"/>
   </apex:outputText>
  </apex:column>
  
  <apex:column headerValue="SFobject" id="col2">
   <apex:inputText value="{!l.FormId__r.Parent_object_Name__c}">
   
       <apex:param value="{!l.formId__r.Parent_object_Name__c}" AssignTo="{!objectName}" />
   </apex:inputText>
  </apex:column>
  
  <apex:column headerValue="SFField" id="col3">
   <apex:inputText value="{!field}" styleClass="fieldInput"/>
  </apex:column>
  <apex:column >
          <apex:commandButton value="Save" action="{!save}"/>
  </apex:column>
  
 </apex:pageBlockTable>

    </apex:pageBlock>
</apex:form>
</apex:page>

controller:


public class definition_overview_controller{ 
 Mapping__c mapp=new Mapping__c();
 //list<Mapping__c> li{get;set;}
 
 public id i;
 public String field{get;set;}
 //public  string x{get;set;}
 public String levelname{get;set;}
 public string objectname{get;set;}
 
 public definition_overview_controller()
 {
  i=ApexPages.CurrentPage().getParameters().get('id');
  
 // li=new list<Mapping__c>();
  //li.add(mapp);
 }
 public list<label__C> label;
 public list<Label__c> getlabel()
 {
  label=[select Name,FormId__c,description__c,Label__c,FormId__r.Parent_object_Name__c from Label__c where FormId__c=:i];
  return label;
 }
 public void Save(){
 
   
            mapp.LabelD__c=levelname;
           // System.debug(mapp);
            mapp.SFObject__c=objectname;
            mapp.SFfield__c=field;
            insert mapp;
          //  li.add(mapp);
    /*      System.debug(li);
     for(integer i=0;i<li.size();i++)
     {
         insert li;
     }*/
         
  
 }
}

Note : i am not able to store multiple record at a time it show Error-->

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LabelID]: [LabelID]
Error is in expression '{!save}' in component <apex:commandButton> in page visualforcepage_webners_assignment_page2: Class.definition_overview_controller.Save: line 31, column 1
 
hi developers , i have an issue that i want to show all the fields labels in a textbox so that i can type few character then it will show all the related labels in there. thank you
i have a vf  page
<apex:page sidebar="false" showHeader="false" controller="definition_overview_controller" tabstyle="Label__c" id="page">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
<script>
function setFocusOnLoad() {}
$(document).ready(function(){
 $(".fieldInput").focusin(function() {
 var tempObj = $(this).closest('td').prev('td').find('input').val();
 if(tempObj.length >0){       
  sleep(100).then(()=>{
   sforce.connection.sessionId='{!GETSESSIONID()}';
   var tempList = sforce.apex.execute("ListofLabel","getAllLabels",{Objname:tempObj});
   $(".fieldInput").autocomplete({source: tempList});              
    });   
   }
});  
});

function sleep (time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}       
</script>
<apex:sectionHeader title="Mapping Object" subtitle="Form" id="header"/>
<apex:form id="form">
<apex:pageBlock id="pageblock" >
 <apex:pageBlockTable title="Related List" value="{!label}" var="l" id="pageblocktable"> 
  <apex:column headerValue="Lebal Name" id="col1" >
      <apex:outputText value="{!l.name}">
     
       <apex:param value="{!l.name}" AssignTo="{!levelName}"/>
   </apex:outputText>
  </apex:column>
  
  <apex:column headerValue="SFobject" id="col2">
   <apex:inputText value="{!l.FormId__r.Parent_object_Name__c}">
   
       <apex:param value="{!l.formId__r.Parent_object_Name__c}" AssignTo="{!objectName}" />
   </apex:inputText>
  </apex:column>
  
  <apex:column headerValue="SFField" id="col3">
   <apex:inputText value="{!field}" styleClass="fieldInput"/>
  </apex:column>
  <apex:column >
          <apex:commandButton value="Save" action="{!save}"/>
  </apex:column>
  
 </apex:pageBlockTable>

    </apex:pageBlock>
</apex:form>
</apex:page>

controller:


public class definition_overview_controller{ 
 Mapping__c mapp=new Mapping__c();
 //list<Mapping__c> li{get;set;}
 
 public id i;
 public String field{get;set;}
 //public  string x{get;set;}
 public String levelname{get;set;}
 public string objectname{get;set;}
 
 public definition_overview_controller()
 {
  i=ApexPages.CurrentPage().getParameters().get('id');
  
 // li=new list<Mapping__c>();
  //li.add(mapp);
 }
 public list<label__C> label;
 public list<Label__c> getlabel()
 {
  label=[select Name,FormId__c,description__c,Label__c,FormId__r.Parent_object_Name__c from Label__c where FormId__c=:i];
  return label;
 }
 public void Save(){
 
   
            mapp.LabelD__c=levelname;
           // System.debug(mapp);
            mapp.SFObject__c=objectname;
            mapp.SFfield__c=field;
            insert mapp;
          //  li.add(mapp);
    /*      System.debug(li);
     for(integer i=0;i<li.size();i++)
     {
         insert li;
     }*/
         
  
 }
}

Note : i am not able to store multiple record at a time it show Error-->

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LabelID]: [LabelID]
Error is in expression '{!save}' in component <apex:commandButton> in page visualforcepage_webners_assignment_page2: Class.definition_overview_controller.Save: line 31, column 1