You need to sign in to do that
Don't have an account?
VRK
Hi
How to Fetch only '"Contract Release' in below JSON Data :::
data->
[{"Date_Reviewed":"1989-05-06","Date_Sent":"1989-05-05","editable":true,"Form":"Contract Revision 1","Id":"a0S3F000001bXAIUA2"},
{"Date_Reviewed":"2019-02-01","Date_Sent":"2019-02-01","editable":true,"Form":"Contract Revision 2","Id":"a0S3F000001bXAJUA2"},
{"Date_Reviewed":"2020-12-27","editable":true,"Form":"Contract Revision 3","Id":"a0S3F000001bXAKUA2"},
{"Date_Reviewed":"2020-01-03","Date_Sent":"2020-01-03","editable":true,"Form":"Contract Release","Id":"a0S3F000001bXALUA2"},
{"Date_Reviewed":"2020-12-29","editable":true,"Form":"Contract Revision 4","Id":"a0S3F000001bXAMUA2"},
{"Date_Reviewed":"2020-12-30","editable":true,"Form":"Contract Revision 5","Id":"a0S3F000001bXANUA2"},
]
My code :
saveDataTable :function(component, event) {
var data = component.get("v.data");
var editedRecords1 = component.find("riderStatusDataTable").get("v.draftValues");
for (var x in data)
{
var d = data[x];
if(d.Form == "Contract Release" ){
TemporaryArray1.Date_Sent__c = editedRecords1[0].Date_Sent;
TemporaryArray1.Date_Reviewed__c = editedRecords1[0].Date_Reviewed;
break;
}
But , this is not Restrict for Contract Release ........its applied for all the Forms . I need this is for only 'Contract Release'...
can anyone help me...
Thanks
VRK
Fetch Record from lighting:dataTable issue
Hi
How to Fetch only '"Contract Release' in below JSON Data :::
data->
[{"Date_Reviewed":"1989-05-06","Date_Sent":"1989-05-05","editable":true,"Form":"Contract Revision 1","Id":"a0S3F000001bXAIUA2"},
{"Date_Reviewed":"2019-02-01","Date_Sent":"2019-02-01","editable":true,"Form":"Contract Revision 2","Id":"a0S3F000001bXAJUA2"},
{"Date_Reviewed":"2020-12-27","editable":true,"Form":"Contract Revision 3","Id":"a0S3F000001bXAKUA2"},
{"Date_Reviewed":"2020-01-03","Date_Sent":"2020-01-03","editable":true,"Form":"Contract Release","Id":"a0S3F000001bXALUA2"},
{"Date_Reviewed":"2020-12-29","editable":true,"Form":"Contract Revision 4","Id":"a0S3F000001bXAMUA2"},
{"Date_Reviewed":"2020-12-30","editable":true,"Form":"Contract Revision 5","Id":"a0S3F000001bXANUA2"},
]
My code :
saveDataTable :function(component, event) {
var data = component.get("v.data");
var editedRecords1 = component.find("riderStatusDataTable").get("v.draftValues");
for (var x in data)
{
var d = data[x];
if(d.Form == "Contract Release" ){
TemporaryArray1.Date_Sent__c = editedRecords1[0].Date_Sent;
TemporaryArray1.Date_Reviewed__c = editedRecords1[0].Date_Reviewed;
break;
}
But , this is not Restrict for Contract Release ........its applied for all the Forms . I need this is for only 'Contract Release'...
can anyone help me...
Thanks
VRK
No you can't use that as there is no form field in draft values.
here is code you have to do:
All Answers
Hi,
you can achieve this using filter:
in filteredData you have the result.
for more info please check this:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
and if it helps you please mark as the best answer.
Hi,
let's see explanation below how the filter will work. (In above code there is typo I have fixed here)
here data have an array of objects. Now if you want to get only those objects which have Form = "Contract Release". you will do this.
this releaseData variable also an array of object but it have only those object which have form = "Contract Release". Now you can work with releaseData. below is the result.
hoe this helps you.
Yes, it is a little bit clear. I added below code let me know if it helps you:
this will make this output:
let me know if you face any problem.
component.find("riderStatusDataTable").get("v.draftValues").
means what you get when you run the above code (JSON structure).
The new Values of Date_Sent,Date_Reviewed values for Contract Release Form...
So , i need to pass these values ..
var myData = JSON.stringify(editedRecords1);
console.log(myData);
[{"Date_Sent":"2020-06-05","Date_Reviewed":"2020-06-05","Id":"a0S3F000001bXALUA2"}]
Hi,
try this:
it will make this output with new dates.
If the above suggestion worked, let us know by marking the answer as "Best Answer" right under the comment which will help the rest of the community should they have a similar issue in the future.
yes as I am testing in a different systems where I do not have those objects that's why I chose it static. so for making it dynamic you can do this:
can we apply similar filter on draft Values also for retrive Only 'Contract Release'.
let editedRecord = component.find("riderStatusDataTable").get("v.draftValues");
i tried bleow line :
let editedRecord1 = editedRecord.filter(dataVal => dataVal.Form == "Contract Release"); ( But display output as BLANK).
The problem of the Above code is : No filter on draft Values, so its applicable for other Forms also .
So i am expecting :::
i need to filter for Contract Release same as data.filter(dataVal => dataVal.Form == "Contract Release") for draftValues
No you can't use that as there is no form field in draft values.
here is code you have to do:
Can you please post this question in another thread as it becomes a very big thread. and if somebody came here he would not understand.
so if your previous query is resolved please mark the above answer as the best answer. And then post new question and share here a link so I can look into it.
releaseData.forEach((elem, index) => {
if(elem.Id == editObj.Id){
valid = true; // this line added now
TemporaryArray1.Date_Sent__c = editObj.Date_Sent;
TemporaryArray1.Date_Reviewed__c = editObj.Date_Reviewed;
}
})
})
Above code , i added valid = true, and write condition in other areas, when this is true, then only execute other part.
So, now its working perfectly.
can you pls suggest me, is there any materials / documents for solve this type of scenarios ?
Thank you very much your help on this.
Nice to hear, It worked for you. Sure as this is a lightning problem but if I say technically it is a javascript problem. Like filtering an array and looping through the array. In your case, it is not a simple array it is an array of an object. You can learn more about javascript new ways of doing stuff from the Mozilla javascript guide. I have added the Mozilla link below you can check and learn. Happy Coding !!😊
https://developer.mozilla.org/en-US/docs/Web/JavaScript
can u pls check below link and let me know any help on this
https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Lightning&criteria=OPENQUESTIONS&id=9062I000000QynlQAC