Copy link to clipboard
Copied
Attached is a form I want the deadline to always be the 5th of the upcoming month. e.g., if the current date is 27th of march, the deadline should always be one month ahead. but in this case, the day would always be 5th of the upcoming month. I hope this can be done!
Thanks in anticipation for a quick response.
I see you don't have field for deadline date, so create a field I named it "Deadline_Date" and add new document level script using this:
var month = util.scand("dd-mmm-yyyy", new Date());
month.setMonth(month.getMonth() +1);
var str = util.printd("dd mmmm, yyyy", month);
var newDate = "05"+str.slice(2);
this.getField("Deadline_Date").value = newDate;
Here is your file with everything above added:
https://drive.google.com/uc?export=download&id=1gm7aW8xUlJx4tbyVimvQ6sW1M9Eybyic
Copy link to clipboard
Copied
I see you don't have field for deadline date, so create a field I named it "Deadline_Date" and add new document level script using this:
var month = util.scand("dd-mmm-yyyy", new Date());
month.setMonth(month.getMonth() +1);
var str = util.printd("dd mmmm, yyyy", month);
var newDate = "05"+str.slice(2);
this.getField("Deadline_Date").value = newDate;
Here is your file with everything above added:
https://drive.google.com/uc?export=download&id=1gm7aW8xUlJx4tbyVimvQ6sW1M9Eybyic
Copy link to clipboard
Copied
Thanks a lot. it worked perfectly
Copy link to clipboard
Copied
There is a problem I didn't anticipate with the above script and needed help with.
I would want it to be amended in such a way that the "Deadline_Date" would only change to the upcoming month when the "Current_Date" crosses the Deadline_Date by one I.e., on the 6th.
I attached the form again.
Thanks in anticipation for a quick response.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you very very very much!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This will fix not displaying deadline but it will still show 'May' because that is how date is calculated, one month from today is 1st may, if you wish to counter that you will need to adapt script.
https://drive.google.com/uc?export=download&id=1t64MxCDBwSpI8SpRqzuM5KMnckCv0OVw
EDIT: Just to add you have errors in every "S/N" fields: it should be 'break' instead of 'breaks'.
Also to speed up your file it would be better to use those scripts in dropdown fields as validation.
Copy link to clipboard
Copied
Thanks for being patient with a novice like me.
I have edited the "S/N" fields.
The Deadline field is still not displaying.
And how do I go about the dropdown fields as validation? I have looked at the validation tab and I'm clueless about what to do.
Thanks in anticipation for a quick response.
Copy link to clipboard
Copied
I thought you said if date is 5th or less you don't want deadline to show?
You should also check 'Commit selected value immediately' under dropdown fields options tab.
You can also remove all scripts from "S/N" fields and just use script in one field to loop through all fields, this is not necessary but is much more efficient to have 1 calculation script instead of 14 because every time something change in file all calculation scripts trigger which slowdown your file.
Also scripts from fields "Employee_Number","Location","Region","Designation" can be implement into one validation script for "Employee_Name" dropdown field.
Copy link to clipboard
Copied
Sorry, I'm not very good at English.
Deadline display is very important. we want to keep track of when Staffs upload their expenses for approval. Expense submission widow opens from the 27th of the month and ends on the 5th of the coming month. thus, the deadline shouldn't change until the doc. date changes to 6th. e.g., if staff A decides not to fill and submit his expense form 27th - 31st and decides to fill it in April, the deadline should not change to May until the document date is 6th of April.
#2 With regards to "S/N" Please enlighten me on how to to it.
#3 how do I also go about implementing "Employee_Number", "Location", "Region", "Designation"into one validation script for "Employee_Name" dropdown field.
Thanks.
Copy link to clipboard
Copied
It took some time but I belive I made all the changes, test everything and let me know if anything needs to fix.
https://drive.google.com/uc?export=download&id=1hSN0szN586okQorCwSAKd1aN7_Mg9VKV
Copy link to clipboard
Copied
I wish I could thank you personally.
Thank you for taking the time to fix my form. You have made my day.
If I notice anything needing some fixing I'll let you know. I hope you don't get tired of me.
Thanks once again for your time.
Copy link to clipboard
Copied
Hello Nesa,
hopefully, you're feeling great.
I would really appreciate your help in applying the same dropdown principle to populate some fields. But this time around I want to use a radio button "Unit" to populate some fields "Signee.0 - Signee.5".
What I really want is if the form user clicks on the top radio button these acronyms
(CM - FD, GBM, AC - Foods, HDOP, CFO, ED - FMCG) should populate the fields "Signee.0 - Signee.5" AND if he clicks the below radio button; these acronyms (CM - HH, GBM, AC - HH, HDOP, CFO, ED - FMCG) should populate the fields "Signee.0 - Signee.5".
I hope it is possible!
Many thanks in anticipation for your kind response.
Copy link to clipboard
Copied
Hello Nesa,
hopefully, you're feeling great.
I would really appreciate your help in applying the same dropdown principle to populate some fields. But this time around I wants to use a radio button "Unit" to populate some fields "Signee.0 - Signee.5".
What I really want is if the form user clicks on the top radio button these acronyms
(CM - FD, GBM, AC - Foods, HDOP, CFO, ED - FMCG) should populate the fields "Signee.0 - Signee.5" AND if he clicks the below radio button; these acronyms (CM - HH, GBM, AC - HH, HDOP, CFO, ED - FMCG) should populate the fields "Signee.0 - Signee.5".
I hope it is possible!
Many thanks in anticipation for your kind response.
Copy link to clipboard
Copied
As Mouse UP event of
Top radio button:
if(event.target.value == 0){
this.getField("Signee.0").value = "CM - FD";
this.getField("Signee.1").value = "GBM";
this.getField("Signee.2").value = "AC - Foods";
this.getField("Signee.3").value = "HDOP";
this.getField("Signee.4").value = "CFO";
this.getField("Signee.5").value = "ED - FMCG";}
Bottom radio button:
if(event.target.value == 1){
this.getField("Signee.0").value = "CM - HH";
this.getField("Signee.1").value = "GBM";
this.getField("Signee.2").value = "AC - HH";
this.getField("Signee.3").value = "HDOP";
this.getField("Signee.4").value = "CFO";
this.getField("Signee.5").value = "ED - FMCG";}
Copy link to clipboard
Copied
Worked perfectly well!
Thanks, Nesa for your help.
Copy link to clipboard
Copied
Hello Nesa,
hopefully, you are having a great time over there. It has been a while since I asked for your help. thus, i am back at it. Attached is something I need some urgent help with if possible.
Thanks in anticipation for a quick response
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Set export value like this:
var list = [
[["-Select Foods-","0"],["ASSORTED CREAM BISCUIT 36*100G","100"],["ASSORTED CREAM BISCUIT 36*110G","200"],["ASSORTED CREAM BISCUIT 48*44G","300"],[ "VANILLA CREAM 48*44G","400"]],
[["-Select Household-","0"],["ACTION 10*1KG","3950"],["ACTION (WHITE) 5KG","2850"], ["ACTION 12*460G","3200"]]];
then as 'Custom calculation script' of "Total" field use this:
var sum = 0;
for(var j=0; j<=2; j++){
if(typeof this.getField("Product."+j).value == "number")
this.getField("Rate."+j).value = this.getField("Product."+j).value;
else
this.getField("Rate."+j).value = "";
if(this.getField("Rate."+j).value && this.getField("QTY."+j).value)
this.getField("Amount."+j).value = Number(this.getField("Rate."+j).value)*Number(this.getField("QTY."+j).value);
else
this.getField("Amount."+j).value = "";
if(this.getField("Amount."+j).valueAsString != "")
sum+= Number(this.getField("Amount."+j).value);}
event.value = sum;
Remove scripts from "Rate" and "Amount" fields.
Copy link to clipboard
Copied
Thanks a lot Nesa. I have glued myself here waiting for your reply.
One more thing, I want to adjust my expense form to have a calculation for "Total_Amount", "Advance_Taken", "Grand_Total".
i would like a situation where "Advance_Taken" to minus the "Total_Amount" and give the "Grand_Total". and I would want the "Grand_Total" to appear in Red if the "Advance_Taken" is greater than the "Total_Amount".
The form is attached.
Thanks.
Copy link to clipboard
Copied
Use this as custom calculation script of "Grand Total" field:
var TA = Number(this.getField("Total Amount").value);
var AT = Number(this.getField("Advance_Taken").value);
var sum = AT-TA;
event.value = sum;
event.target.textColor = AT>TA ? color.red : color.black;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Perhaps I didn't understand right, what should calculation be?
Copy link to clipboard
Copied
For example,
A staff has an option to apply for an advance for out of office assignment or go on the assignment without applying for any advance. when he is done; he would now submit the expense form for reimbursement or return some balances to the company depending on the expense incurred.
if staff A collected 2,000 from the company and incurred 1,500 expenses. he is to return 500 to the company which is to be displayed as this '500' and if he incurred 3000, he would be credited 1000 which should be displayed as a normal text color.
another thing I would want is that the '500' should be displayed with the word 'refund 500' if its possible.
Thanks