- sharath chandra parsi
- NEWBIE
- 10 Points
- Member since 2016
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
2Replies
Event Monitoring
I created a form where i can add a task, Display the saved records. I want to delete any task which is not needed. So I provided delete button in the list of tasks. I am trying to delete the task with Event handlers.
Parent Component:
<aura:component controller="taskController">
<aura:attribute type="task__c" name="task" default="{'sobjectType':'task__c',
'Name':'',
'Due_Date__c':''}" />
<aura:attribute type="task__c[]" name="tasks" />
<form>
<div class="slds-form-element">
<label class="slds-form-element_label">Task Name</label>
<div class="slds-form-element_control">
<ui:inputText aura:id="taskName" class="slds-input slds-size--1-of-3" value="{!v.task.Name}" />
</div>
</div>
<div class="slds-form-element">
<label class="slds-form-element_label">priority value</label>
<div class="slds-form-element_control">
<ui:inputSelect aura:id="taskPriority" class="slds-input slds-size--1-of-3" value="{!v.task.Priority__c}">
<ui:inputSelectOption label="1" text="1" />
<ui:inputSelectOption label="2" text="2" />
<ui:inputSelectOption label="3" text="3" />
<ui:inputSelectOption label="4" text="4" />
<ui:inputSelectOption label="5" text="5" />
</ui:inputSelect>
</div>
</div>
<div class="slds-form-element">
<label class="slds-form-element_label">Due Date</label>
<div class="slds-form-element_control">
<ui:inputDate aura:id="taskDate" displayDatePicker="true" class="slds-input slds-size--1-of-3" value="{!v.task.Due_Date__c}" />
</div>
</div>
<div class="slds-form-element">
<ui:Button label="Create Task" class="slds-button slds-button--success" press="{!c.insertTask}" />
</div>
</form>
<ui:Button label="View Today's Task" class="slds-button slds-button--success" press="{!c.displayTasks}" />
<ui:Button label="View Daily Task" class="slds-button slds-button--success" press="{!c.displayGroupedTasks}" />
<div id="errorMessage"></div>
<aura:iteration items="{!v.tasks}" var="task1">
<c:taskListItem task2="{!task1}"/>
</aura:iteration>
</aura:component>
taskFormController:
({
insertTask : function(component, event, helper) {
if(helper.validateTask(component)){
helper.createTask(component);
}
},
displayTasks : function(component, event, helper){
helper.loadRequiredTask(component);
},
displayGroupedTasks : function(component, event, helper){
helper.loadGroupedTasks(component);
}
})
taskFormHelper:
({
validateTask: function(component) {
var validTask = true;
var taskName = component.find("taskName");
var taskNameValue = taskName.get("v.value");
if ($A.util.isEmpty(taskNameValue)) {
alert("Name failure" + taskNameValue);
validTask = false;
}
var taskPriority = component.find("taskPriority");
var taskPriorityValue = taskPriority.get("v.value");
if ($A.util.isEmpty(taskPriorityValue)) {
validTask = false;
console.log("value failure" + taskPriorityValue);
}
return validTask;
},
createTask: function(component) {
var action = component.get("c.saveTask");
var task =component.get('v.task');
action.setParams({
"task": task
});
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
console.log("Successfully Inserted");
component.set("v.tasks",response.getReturnValue());
}
})
$A.enqueueAction(action);
},
loadRequiredTask: function(component){
var action = component.get("c.loadTasks");
action.setCallback(this,function(response){
var state = response.getState();
if(component.isValid()&& state=='SUCCESS'){
console.log(typeof(response.getReturnValue()));
if(response.getReturnValue().length>0)
component.set("v.tasks", response.getReturnValue());
else{
console.log("In empty");
document.getElementById("errorMessage").innerHTML='<p>"There are no Tasks pending for Today"</p>';
}
}
})
$A.enqueueAction(action);
},
loadGroupedTasks: function(component) {
var action = component.get("c.loadGroupedTasks");
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
console.log("Successfully Retrieved");
component.set("v.tasks",response.getReturnValue());
}
})
$A.enqueueAction(action);
}
})
taskListItem.cmp:
<aura:component controller="taskListController">
<aura:attribute type="task__c" name="task2" />
<aura:registerEvent name="deleteTask" type="c:TaskDeleteEvent" />
<aura:handler name="TaskDeleteEvent" event="c:TaskDeleteEvent" action="{!c.deleteTask}"/>
<p>
Task Name:
<ui:outputText value="{!v.task2.Name}" />
</p>
<br></br>
<p>
Priority Value:
<ui:outputText value="{!v.task2.Priority__c}" />
</p>
<br></br>
<p>
Due Date:
<ui:outputDate value="{!v.task2.Due_Date__c}" />
</p>
<br></br>
<p>
<ui:Button class="slds-button" label="Delete" press="{!c.deleteTask}" />
</p>
-------------------------------------------------------------------------------------------------
</aura:component>
taskListItemController.js:
({
deleteTask : function(component, event, helper) {
var deleteTask = component.get("v.task2");
var TaskDeleteEvent = component.getEvent("deleteTask");
TaskDeleteEvent.setParams({"task2":deleteTask}).fire();
}
})
taskListController.apxc:
public class taskListController {
@AuraEnabled
public static void deleteTask(sobject task){
delete task;
}
}
TaskDeleteEvent.evt:
<aura:event type="COMPONENT" description="Event template" >
<aura:attribute name="task2" type="task__c" />
</aura:event>
Delete is not working.
Parent Component:
<aura:component controller="taskController">
<aura:attribute type="task__c" name="task" default="{'sobjectType':'task__c',
'Name':'',
'Due_Date__c':''}" />
<aura:attribute type="task__c[]" name="tasks" />
<form>
<div class="slds-form-element">
<label class="slds-form-element_label">Task Name</label>
<div class="slds-form-element_control">
<ui:inputText aura:id="taskName" class="slds-input slds-size--1-of-3" value="{!v.task.Name}" />
</div>
</div>
<div class="slds-form-element">
<label class="slds-form-element_label">priority value</label>
<div class="slds-form-element_control">
<ui:inputSelect aura:id="taskPriority" class="slds-input slds-size--1-of-3" value="{!v.task.Priority__c}">
<ui:inputSelectOption label="1" text="1" />
<ui:inputSelectOption label="2" text="2" />
<ui:inputSelectOption label="3" text="3" />
<ui:inputSelectOption label="4" text="4" />
<ui:inputSelectOption label="5" text="5" />
</ui:inputSelect>
</div>
</div>
<div class="slds-form-element">
<label class="slds-form-element_label">Due Date</label>
<div class="slds-form-element_control">
<ui:inputDate aura:id="taskDate" displayDatePicker="true" class="slds-input slds-size--1-of-3" value="{!v.task.Due_Date__c}" />
</div>
</div>
<div class="slds-form-element">
<ui:Button label="Create Task" class="slds-button slds-button--success" press="{!c.insertTask}" />
</div>
</form>
<ui:Button label="View Today's Task" class="slds-button slds-button--success" press="{!c.displayTasks}" />
<ui:Button label="View Daily Task" class="slds-button slds-button--success" press="{!c.displayGroupedTasks}" />
<div id="errorMessage"></div>
<aura:iteration items="{!v.tasks}" var="task1">
<c:taskListItem task2="{!task1}"/>
</aura:iteration>
</aura:component>
taskFormController:
({
insertTask : function(component, event, helper) {
if(helper.validateTask(component)){
helper.createTask(component);
}
},
displayTasks : function(component, event, helper){
helper.loadRequiredTask(component);
},
displayGroupedTasks : function(component, event, helper){
helper.loadGroupedTasks(component);
}
})
taskFormHelper:
({
validateTask: function(component) {
var validTask = true;
var taskName = component.find("taskName");
var taskNameValue = taskName.get("v.value");
if ($A.util.isEmpty(taskNameValue)) {
alert("Name failure" + taskNameValue);
validTask = false;
}
var taskPriority = component.find("taskPriority");
var taskPriorityValue = taskPriority.get("v.value");
if ($A.util.isEmpty(taskPriorityValue)) {
validTask = false;
console.log("value failure" + taskPriorityValue);
}
return validTask;
},
createTask: function(component) {
var action = component.get("c.saveTask");
var task =component.get('v.task');
action.setParams({
"task": task
});
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
console.log("Successfully Inserted");
component.set("v.tasks",response.getReturnValue());
}
})
$A.enqueueAction(action);
},
loadRequiredTask: function(component){
var action = component.get("c.loadTasks");
action.setCallback(this,function(response){
var state = response.getState();
if(component.isValid()&& state=='SUCCESS'){
console.log(typeof(response.getReturnValue()));
if(response.getReturnValue().length>0)
component.set("v.tasks", response.getReturnValue());
else{
console.log("In empty");
document.getElementById("errorMessage").innerHTML='<p>"There are no Tasks pending for Today"</p>';
}
}
})
$A.enqueueAction(action);
},
loadGroupedTasks: function(component) {
var action = component.get("c.loadGroupedTasks");
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
console.log("Successfully Retrieved");
component.set("v.tasks",response.getReturnValue());
}
})
$A.enqueueAction(action);
}
})
taskListItem.cmp:
<aura:component controller="taskListController">
<aura:attribute type="task__c" name="task2" />
<aura:registerEvent name="deleteTask" type="c:TaskDeleteEvent" />
<aura:handler name="TaskDeleteEvent" event="c:TaskDeleteEvent" action="{!c.deleteTask}"/>
<p>
Task Name:
<ui:outputText value="{!v.task2.Name}" />
</p>
<br></br>
<p>
Priority Value:
<ui:outputText value="{!v.task2.Priority__c}" />
</p>
<br></br>
<p>
Due Date:
<ui:outputDate value="{!v.task2.Due_Date__c}" />
</p>
<br></br>
<p>
<ui:Button class="slds-button" label="Delete" press="{!c.deleteTask}" />
</p>
-------------------------------------------------------------------------------------------------
</aura:component>
taskListItemController.js:
({
deleteTask : function(component, event, helper) {
var deleteTask = component.get("v.task2");
var TaskDeleteEvent = component.getEvent("deleteTask");
TaskDeleteEvent.setParams({"task2":deleteTask}).fire();
}
})
taskListController.apxc:
public class taskListController {
@AuraEnabled
public static void deleteTask(sobject task){
delete task;
}
}
TaskDeleteEvent.evt:
<aura:event type="COMPONENT" description="Event template" >
<aura:attribute name="task2" type="task__c" />
</aura:event>
Delete is not working.
- sharath chandra parsi
- February 09, 2017
- Like
- 0
- Continue reading or reply
The campingList component doesn't have a Name field using an inputText UI component.
component code:
<aura:component>
<aura:attribute name="items" type="Camping_Item__c[]" />
<aura:attribute name="newItem" type="Camping_Item__c" default="{
'sObjectType' : 'Camping_Item__c',
'Name' : '',
'Price__c' : 0 ,
'Quantity__c' : 0}"/>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputText aura:id="name" label="Name"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newItem.name__c}"
required="true"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputCurrency aura:id="price" label="Price"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newItem.Price__c}"
required="true"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputNumber aura:id="Quantity" label="Quantity"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newItem.Quantity__c}"
required="true"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:button label="Add Camping Item"
class="slds-input"
labelClass="slds-form-element__label"
press="{!c.submitForm}"/>
</div>
</div>
<aura:iteration items="{!v.items}" var="item">
<c:campingListItem item="{!item}"/>
</aura:iteration>
</aura:component>
controller code:
({
submitForm : function(component, event, helper) {
var validItem = true;
if($A.utils.isEmpty(component.find("name").get("v.value"))){
validItem = false;
component.find("name").set("v.errors",[{message : "Please give a name"}]);
}
else{
component.find("name").set("v.errors" , null);
}
if($A.utils.isEmpty(component.find("price").get("v.value"))){
validItem = false;
component.find("price").set("v.errors",[{message : "Please give a price"}]);
}
else{
component.find("price").set("v.errors" , null);
}
if($A.utils.isEmpty(component.find("Quantity").get("v.value"))){
validItem = false;
component.find("Quantity").set("v.errors",[{message : "Please give a Quantity"}]);
}
else{
component.find("Quantity").set("v.errors" , null);
}
if(validItem){
var item = component.get("v.newItem");
helper.createItem(component , item);
}
}
})
Helper code:
({
createItem : function(component , newItem) {
var items = component.get("v.items");
items.push(newItem);
component.set("v.items" , items);
}
})
<aura:component>
<aura:attribute name="items" type="Camping_Item__c[]" />
<aura:attribute name="newItem" type="Camping_Item__c" default="{
'sObjectType' : 'Camping_Item__c',
'Name' : '',
'Price__c' : 0 ,
'Quantity__c' : 0}"/>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputText aura:id="name" label="Name"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newItem.name__c}"
required="true"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputCurrency aura:id="price" label="Price"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newItem.Price__c}"
required="true"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputNumber aura:id="Quantity" label="Quantity"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newItem.Quantity__c}"
required="true"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:button label="Add Camping Item"
class="slds-input"
labelClass="slds-form-element__label"
press="{!c.submitForm}"/>
</div>
</div>
<aura:iteration items="{!v.items}" var="item">
<c:campingListItem item="{!item}"/>
</aura:iteration>
</aura:component>
controller code:
({
submitForm : function(component, event, helper) {
var validItem = true;
if($A.utils.isEmpty(component.find("name").get("v.value"))){
validItem = false;
component.find("name").set("v.errors",[{message : "Please give a name"}]);
}
else{
component.find("name").set("v.errors" , null);
}
if($A.utils.isEmpty(component.find("price").get("v.value"))){
validItem = false;
component.find("price").set("v.errors",[{message : "Please give a price"}]);
}
else{
component.find("price").set("v.errors" , null);
}
if($A.utils.isEmpty(component.find("Quantity").get("v.value"))){
validItem = false;
component.find("Quantity").set("v.errors",[{message : "Please give a Quantity"}]);
}
else{
component.find("Quantity").set("v.errors" , null);
}
if(validItem){
var item = component.get("v.newItem");
helper.createItem(component , item);
}
}
})
Helper code:
({
createItem : function(component , newItem) {
var items = component.get("v.items");
items.push(newItem);
component.set("v.items" , items);
}
})
- sharath chandra parsi
- December 24, 2016
- Like
- 0
- Continue reading or reply
Unable to limit the size of decimal in formula field..!!
I am trying to write a formula field where i used arithmetic divison. I want to limit the size of decimal to 2 places which can be done using setScale in apex. But unable to apply the same to formula field.
formula is of kind TEXT(x/y) ------ working fine.
TEXT((x/y).setScale(2)) ----------- Not working.
formula is of kind TEXT(x/y) ------ working fine.
TEXT((x/y).setScale(2)) ----------- Not working.
- sharath chandra parsi
- October 07, 2016
- Like
- 0
- Continue reading or reply
When using /sfc/servlet.shepherd/document/download/ <ContentDocument IDs> , can we rename the zip folder document?
Hello
I have used the Custom button (/sfc/servlet.shepherd/document/download/ ) to download all the files realed to an object. The Zip folder always has a name “downloaded-content”. So I need to change this name to “file.zip”.
Is it possible to rename the Zip folder?
It is pretty urgent.
Thanks
I have used the Custom button (/sfc/servlet.shepherd/document/download/ ) to download all the files realed to an object. The Zip folder always has a name “downloaded-content”. So I need to change this name to “file.zip”.
Is it possible to rename the Zip folder?
It is pretty urgent.
Thanks
- khushbu parmar 5
- May 27, 2020
- Like
- 0
- Continue reading or reply
'Sharing Setting' option explanation in Master-Detail Relationship field
Hi,
I am creating a Master-Detail Relationship field on Child object.In step 3,there is a option called "Sharing Setting".I tried to understand through experiments but could not understand the significance of this setting.
Assume that i have selected "Read Only" here.In profile settings i have given basic 'Read' access for both master and Child objects.The Sharing setting for Master is 'Public Read-only'.Kindly explain how the records will be impacted by this setting.
Thanks.
- eswarsf
- June 21, 2011
- Like
- 0
- Continue reading or reply