You need to sign in to do that
Don't have an account?
Rajesh Kumar Maharana
Create task object records based on contact names in the multi-select picklist
I have created custom multipicklist jQuery. In the multipicklist I have shown the contact names. Whenever I select the contact names, it is showing contact names in the label. It is also counting no.of contacts I have selected.
Activity Objective==> Wherever you see Activity Objective in the VFP, I have added the codes for the multi-picklist.
ISSUE: whenever I select the contact names (either 1 or more than 1) from the multi-picklist and click on save. It will save the record, but in the name field in the Task object will be blank. If I have selected 1 0r more than 1 contact names, it will create single record in the Task object and the name field will be blank.
REQUIREMENT: Now I want that, how many contact names I have selected from the multi-picklist. That many records will be created in the Task Object.
Already in the controller, record creation code is written. It is checking the contact name isChecked=true, then it will create the record.
In my code, it is taking isChecked=false. So it is not able to creat
e the record. Due to limitation, not able to upload whole code.
Activity Objective==> Wherever you see Activity Objective in the VFP, I have added the codes for the multi-picklist.
ISSUE: whenever I select the contact names (either 1 or more than 1) from the multi-picklist and click on save. It will save the record, but in the name field in the Task object will be blank. If I have selected 1 0r more than 1 contact names, it will create single record in the Task object and the name field will be blank.
REQUIREMENT: Now I want that, how many contact names I have selected from the multi-picklist. That many records will be created in the Task Object.
Already in the controller, record creation code is written. It is checking the contact name isChecked=true, then it will create the record.
In my code, it is taking isChecked=false. So it is not able to creat
<apex:page standardController="Task" id="thePageId" extensions="NewTaskCtrl" tabStyle="Task" action="{!loadNewTask}"> <apex:outPutPanel id="myMSG"> <apex:pageMessages id="msg" /> </apex:outPutPanel> <apex:slds /> <apex:form id="newTaskPage"> <!-- CDN links for the multiple picklist --> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <link href="https://www.jqueryscript.net/css/jquerysctipttop.css?v3" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"/> <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@dashboardcode/bsmultiselect@0.5.40/dist/js/BsMultiSelect.min.js"></script> <!-- / Activity Objective - New picklist code--> <apex:actionFunction action="{!filterFields}" name="filterFields" reRender="myMSG,taskInfo" > <apex:param value="" name="tType" /> </apex:actionFunction> <apex:sectionHeader title="Task" subtitle="New Task"/> <apex:inputHidden value="{!inputValue}" id="theHiddenInput"/> <div class="slds-card"> <div class="slds-card__header slds-grid slds-border_bottom slds-p-bottom_small" style="background-color: #fafaf9;"> <div class="slds-media slds-media_center slds-has-flexi-truncate"> <div class="slds-media__body"> <h2 class="slds-card__header-title slds-text-heading_small"> Task Edit </h2> </div> <div class="slds-no-flex"> <apex:commandButton action="{!performSave}" title="Save" value="Save" styleClass="slds-button slds-button_brand"/> <apex:commandButton action="{!cancel}" title="Cancel" value="Cancel" styleClass="slds-button slds-button_neutral"/> </div> </div> </div> <div class="slds-card__body slds-p-horizontal_small"> <div class="slds-m-bottom_small slds-p-around_xx-small" style="background-color: #fafaf9;"><strong>Related To</strong></div> <div class="slds-form slds-form_horizontal"> <div> <div style="max-width: 600px;"> <apex:outputPanel styleClass="relatedToSection"> <div class="slds-form-element"> <apex:outputLabel value="Account" styleClass="slds-form-element__label"/> <div class="slds-form-element__control slds-m-top_xxx-small"> <apex:outputField value="{!taskObjectParent.WhatId}" title="This will contain Related Account" label="Account" /> </div> </div> <apex:pageBlock id="OfficeContactList"> <!-- rendered="{!IF((taskObjectParent.Id = null),true,false)}" --> <apex:outputPanel style="display:none" styleclass="taskContactMultiList"> <div class="slds-form-element"> <apex:outputLabel value="Select Contact to create task" styleClass="slds-form-element__label" id="con12"/> <div class="slds-form-element__control" style="padding-right: 82px;"> <!-- Activity Objective --> <!-- Show the multiple picklist values and binding--> <div class="container"> <select name="contactNames" id="example" class="form-control" multiple="multiple" onChange="countSelectedCheckbox()"> <apex:repeat value="{!avaiableContactlList}" var="con" id="conTable"> <option value="{!con.isChecked}" id="opt">{!con.Name}</option> <!---value is changed --> </apex:repeat> </select> </div> <!-- / Activity Objective --> Total Number of Selected record :<span style="font-weight:bold" id="selContactSize">0</span> </div> </div> </apex:outputPanel> </apex:pageBlock> <div class="slds-form-element"> <apex:outputLabel value="Topics Discussed" styleClass="slds-form-element__label"/> <apex:outputPanel id="refreshing"> <div class="slds-form-element__control" style="padding-right: 82px;"> <div class="slds-scrollable_y slds-m-top_x-small slds-m-bottom_small slds-p-around_x-small" style="max-height: 90px; border: 1px solid #dddbda; border-radius: .25rem;"> <table> <apex:repeat value="{!avaiableTopicList}" var="topic"> <tr> <td width="20" class="slds-p-bottom_x-small"> <span class="slds-checkbox slds-checkbox_standalone"> <apex:inputCheckbox value="{!topic.isChecked}" onclick="selectAllCheckboxes('topicCheckBoxId')" id="topicCheckBoxId"/> <span class="slds-checkbox_faux"></span> </span> </td> <td class="slds-p-bottom_x-small"> <label> {!topic.Name} </label> </td> </tr> </apex:repeat> </table> </div> Total Number of Selected record :<span style="font-weight:bold" id="selTopicSize">{!totalAvaiableTopic}</span> </div> </apex:outputPanel> </div> </div> </div> </div> </div> <div class="slds-card__footer slds-text-align_right"> <apex:commandButton action="{!performSave}" title="Save" value="Save" styleClass="slds-button slds-button_brand"/> <apex:commandButton action="{!cancel}" title="Cancel" value="Cancel" styleClass="slds-button slds-button_neutral"/> </div> </div> <script> function setFocusOnLoad() {} function toggleComponent(taskType,componentToToggle,taskId){ console.log('taskId : '+taskId); //filterFields(); if(taskId == 'NULL' || taskId == ''){ var contactComponent = document.getElementsByClassName(componentToToggle)[0]; var selectedValue = taskType.value; console.log(componentToToggle); if(selectedValue == 'Physician-to-Physician Visit' || selectedValue == 'Sports Medicine' ){ contactComponent.style.display ='block'; }else{ contactComponent.style.display ='none'; } }else{ var contactComponent = document.getElementsByClassName(componentToToggle)[0]; var selectedValue = taskType.value; console.log(componentToToggle); var oldTaskType = String(document.getElementById('thePageId:newTaskPage:theHiddenInput').value); if((oldTaskType != 'Physician-to-Physician Visit' && selectedValue == 'Physician-to-Physician Visit') || (oldTaskType != 'Sports Medicine' && selectedValue == 'Sports Medicine')){ contactComponent.style.display ='block'; }else{ contactComponent.style.display ='none'; } } //alert(taskType.value); filterFields(taskType.value); } function selectAllCheckboxes(receivedInputID){ var inputCheckBox = document.getElementsByTagName("input"); var totalCount = 0; for(var i=0; i<inputCheckBox.length; i++){ if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){ if(inputCheckBox[i].checked == true){ //alert("inputCheckBox[i].checked==>>"+inputCheckBox[i].checked); totalCount = totalCount + 1; } } } //console.log('====>' + totalCount); if(receivedInputID=='contactCheckBoxId'){ document.getElementById('selContactSize').innerHTML = totalCount; }else if(receivedInputID=='goalCheckBoxId'){ document.getElementById('setGoalsLength').innerHTML = totalCount; }else if(receivedInputID=='topicCheckBoxId'){ document.getElementById('selTopicSize').innerHTML = totalCount; } } // Js file to show the multiple picklist. $("select[multiple='multiple']").bsMultiSelect(); // code to calculate the count of selected picklist values **function countSelectedCheckbox(){ var totalCount = $("select#example>option:selected").length; document.getElementById('selContactSize').innerHTML = totalCount; } </script> </apex:form> </apex:page>
e the record. Due to limitation, not able to upload whole code.
Rajesh Kumar Maharana
SUPRAKASH Marandi
I want to fetch the records of Accounts,contacts https://alllyricszone.in/
Mark Stven
Can i use this code in my chemical (https://researchemicalsforsale.com) website?