Access NSDictionary values - ios6

I have a JSon object like this
{
Attendance = {
Attendance = (
{
EmployeeCode = 7593;
InDate = "27/02/2013";
InTime = "08:11";
InTime2 = "00:00";
OutDate = "27/02/2013";
OutDate2 = "01/01/1901";
OutTime = "17:42";
OutTime2 = "00:00";
Present = 1;
}
);
AttendanceCount = 1;
};
AuthPersons = {
WFAuthCount = 1;
WfAuthPersons = (
{
LsAuthls = (
{
AuthEmployeeName = "SAMPLE NAME";
EmployeeCode = 4813;
}
);
RequestTypeCode = 5;
WFID = 99;
"WF_LevelID" = 2;
WorkFlowName = "EHL - Group HR (Kanchana/Asitha)";
}
);
};
}
What I wanted is to get these employeecode,IntDate... seperately So I get a seperate NSDictionary NSDictionary *summary = [resultJSON objectForKey:#"Attendance"];
and return it into my Viewcontroller method inside my Viewcontroller I have done like this.
` nsDicttendanceReqDate = [[ws GetWorkflowInfoAttendanceRequest:[NSString stringWithFormat:#"%d",usr.empCode] : #"5" :usr.stringRequestDate] copy];
dicDates= [nsDicttendanceReqDate objectForKey:#"Attendance"] ;
//dicDates=[nsDicttendanceReqDatey JSONValue];
NSLog(#"%d",[dicDates count]);
NSLog(#"DIC DATES%#",dicDates);
NSLog(#"%#",nsDicttendanceReqDate);
if ([nsDicttendanceReqDate count] > 0 ) {
NSLog(#"TESTING---------- %#",[dicDates valueForKey:#"EmployeeCode"]);
NSLog(#"TESTING---------- %#",[dicDates valueForKey:#"OutDate"] );
NSLog(#"TESTING---------- %#",[dicDates valueForKey:#"InDate"] );`
But these are getting inside paranthesis. How can I solve this.Any one can tell me how to extract this values.

Try This.It might be a help.
NSDictionary *summary = [resultJSON valueForKey:#"Attendance"]objectAtIndex:0];

Related

How does "plugin.tx_solr.query.fields " work?

I need to be able to search by the News Tags property.
This typoscript is working fine, but when I input a tag (exact same string) from a News into Solr's search box I don't get any results.
According to "lorenz" in this answer I neede to add my dynamic fields (I believe) to "plugin.tx_solr.query.fields" but this poor documentation doesn't help me.
I added the following to that typoscript but when I use the searchbox to look for exactly the name of my tag I get no results.
(plugin.tx_solr.query.fields = tags_stringM)
Does anybody have any code that I can use as an example?
plugin.tx_solr{
search {
initializeWithEmptyQuery = 1
showResultsOfInitialEmptyQuery = 1
showEmptyFacets = 1
faceting = 1
faceting {
facets {
mediatype {
label = Facet dos
field = categorytitle_stringS
}
}
}
}
index.queue {
custom_news = 1
custom_news {
table = tx_news_domain_model_news
fields {
abstract = teaser
author = author
authorEmail_stringS = author_email
title = title
datetime_stringS = TEXT
datetime_stringS {
field = datetime
date = d.m.Y H:i
}
titlehr_stringS = TEXT
titlehr_stringS {
field = title_hr
}
teaser_stringS = TEXT
teaser_stringS {
field = teaser
}
datetime_dateS = TEXT
datetime_dateS {
field = datetime
date = Y-m-d\TH:i:s\Z
}
content = SOLR_CONTENT
content {
cObject = COA
cObject {
10 = TEXT
10 {
field = bodytext
noTrimWrap = || |
}
20 = TEXT
20 {
field = tags_stringM
noTrimWrap = || |
}
}
}
categorytitle_stringS = SOLR_RELATION
categorytitle_stringS {
localField = categories
multiValue = 1
}
categoryuid_stringS = SOLR_RELATION
categoryuid_stringS {
localField = categories
foreignLabelField = uid
multiValue = 1
}
keywords = SOLR_MULTIVALUE
keywords {
field = keywords
}
tags_stringM = SOLR_RELATION
tags_stringM {
localField = tags
label = Tags
multiValue = 1
}
tagshr_stringM = SOLR_RELATION
tagshr_stringM {
localField = tags
label = Tags hr
foreignLabelField = title_hr
multiValue = 1
}
mediatypehr_intS = TEXT
mediatypehr_intS {
field = media_type_hr
}
mediatypede_intS = TEXT
mediatypede_intS {
field = media_type_de
}
image_stringS = FILES
image_stringS {
references {
table = tx_news_domain_model_news
uid.field = uid
fieldName = fal_media
}
begin = 0
maxItems = 1
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
file.maxW = 330
#wrap = |
}
}
url = CASE
url {
key.field = type
# Internal
1 = TEXT
1 {
if.isTrue.field = internalurl
typolink.parameter.field = internalurl
typolink.useCacheHash = 1
typolink.returnLast = url
}
# External
2 = TEXT
2 {
if.isTrue.field = externalurl
field = externalurl
}
default = TEXT
default {
typolink.parameter = {$plugin.tx_news.settings.detailPid}
typolink.additionalParams = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]={field:uid}&L={field:__solr_index_language}
typolink.additionalParams.insertData = 1
typolink.useCacheHash = 1
typolink.returnLast = url
}
}
}
attachments = 1
attachments {
fields = fal_related_files
fileExtensions = *
}
}
}
}
plugin.tx_solr.logging.indexing.queue.news = 1
Aside from defining the fields for indexing you also need to declare these fields as relevant for search. (and with a weight how important they are for searching)
One possible solution could be like in this part of typoscript:
plugin {
tx_solr {
search {
query {
queryFields := addToList(categorytitle_stringS^2.0,keywords2.0,tags_stringM^2.0, tagshr_stringM^2.0)
}
}
}
}
see manual

2 object of same type returns true when != checked

I am using model.GetType().GetProperties() with foreach to compare properties of 2 object of same class.
like this
foreach (var item in kayit.GetType().GetProperties())
{
var g = item.GetValue(plu);
var b = item.GetValue(kayit);
if (g is string && b is string&& g!=b)
{
a += item.Name + "*";
}
else if (g is DateTime&& b is DateTime&& g!=b)
{
a += item.Name + "*";
}
}
But the problem is even if they have the same value g!=b returns a true all the time. I have used a break point to prove this and they are literally same thing. Actually I am taking the value putting it in textbox then creating another class after button click and comaring to see the changed properties. So even if I don't change anything it doesn't read the mas equals. Can someone help me about this please?
more info:
I get the plu from database and populate my control with it:
txtorder.Text = plu.OrderNo;
dtporder.Value = nulldate(plu.OrderDate);
dtp1fit.Value = nulldate(plu.FirstFitDate);
dtp1yorum.Value = nulldate(plu.FirstCritDate);
dtp2fit.Value = nulldate(plu.SecondFitDate);
dtp2yorum.Value = nulldate(plu.SecondCritDate);
dtpsizeset.Value = nulldate(plu.SizeSetDate);
dtpsizesetok.Value = nulldate(plu.SizeSetOkDate);
dtpkumasplan.Value = nulldate(plu.FabricOrderByPlan);
txtTedarikci.Text = plu.Fabric_Supplier;
dtpkumasFP.Value = nulldate(plu.FabricOrderByFD);
dtpfabarrive.Value = nulldate(plu.FabricArrive);
dtpbulk.Value = nulldate(plu.BulkFabricDate);
dtpbulkok.Value = nulldate(plu.BulkConfirmDate);
dtpaccessory.Value = nulldate(plu.AccessoriesDate);
dtpaccessoryarrive.Value = nulldate(plu.AccessoriesArriveDate);
dtpcutok.Value = nulldate(plu.ProductionStartConfirmation);
dtpcutstart.Value = nulldate(plu.ProductionStart);
dtpshipmentdate.Value = nulldate(plu.ShipmentDate);
dtpshipmentsample.Value = nulldate(plu.ShipmentSampleDate);
dtpshippedon.Value = nulldate(plu.Shippedon);
nulldate is just a method where I change null values to my default value.
And this is what I do after button click:
var kayit = new uretim();
kayit.OrderNo = txtorder.Text.ToUpper();
kayit.OrderDate = vdat(dtporder.Value);
kayit.FirstFitDate = vdat(dtp1fit.Value);
kayit.FirstCritDate = vdat(dtp1yorum.Value);
kayit.SecondFitDate = vdat(dtp2fit.Value);
kayit.SecondCritDate = vdat(dtp2yorum.Value);
kayit.SizeSetDate = vdat(dtpsizeset.Value);
kayit.SizeSetOkDate = vdat(dtpsizesetok.Value);
kayit.FabricOrderByPlan = vdat(dtpkumasplan.Value);
kayit.Fabric_Supplier = txtTedarikci.Text;
kayit.FabricOrderByFD = vdat(dtpkumasFP.Value);
kayit.FabricArrive = vdat(dtpfabarrive.Value);
kayit.BulkFabricDate = vdat(dtpbulk.Value);
kayit.BulkConfirmDate = vdat(dtpbulkok.Value);
kayit.AccessoriesDate = vdat(dtpaccessory.Value);
kayit.AccessoriesArriveDate = vdat(dtpaccessoryarrive.Value);
kayit.ProductionStartConfirmation = vdat(dtpcutok.Value);
kayit.ProductionStart = vdat(dtpcutstart.Value);
kayit.ShipmentDate = vdat(dtpshipmentdate.Value);
kayit.ShipmentSampleDate = vdat(dtpshipmentsample.Value);
kayit.Shippedon = vdat(dtpshippedon.Value);
kayit.Status = true;
kayit.WrittenDate = DateTime.Now;
kayit.GuidKey = plu.GuidKey != null ? plu.GuidKey : Guid.NewGuid().ToString("N");
I have proven by breakpoint that values are actually same. But the != check retruns a true.
When you are doing
g != b
compiler doesn't know that these objects are strings to compare so it compares their references. You can do:
g.Equals(b) //be carefull if one of them is null
or
g.ToString() != b.ToString()
EDIT
You can compare them after you check the type:
if (g is string && b is string)
{
if( g.ToString() != b.ToString() ){
}
}

Filter 2 struct/ arrays by mapping by specific

Im a new user using swift 3 and xcode 8.3. Currently facing a problem to filter 2 array/struc where in console output as below:
A_List : Optional([117, 115, 18])
B_List : Optional([{
URL = "169.jpeg";
categories = "A";
description = "description XXX";
height = 128;
id = 1;
likes = "1.00";
name = "Cake - Baked";
price = "13.78";
width = 128;
}, {
URL = "1622.jpeg";
categories = "A";
description = "Baked till golden";
height = 128;
id = 15;
likes = "1.00";
name = "Croissant";
price = "3.71";
width = 128;
}, {
URL = "11.jpeg";
categories = "A";
description = "description Crispy.";
height = 128;
id = 18;
likes = "1.00";
name = "Plain";
price = "2.65";
width = 128;
}, {
URL = "1622.jpeg";
categories = "A";
description = "A ";
height = 128;
id = 103;
likes = "1.00";
name = "America Pie";
price = "2.12";
width = 128;
}, {
URL = "11.jpeg";
categories = "B";
description = "Puff";
height = 128;
id = 115;
likes = "1.00";
name = "Puff";
price = "2.12";
width = 128;
}, {
URL = "168.jpeg";
categories = "C";
description = "description YYY";
height = 128;
id = 117;
likes = "1.00";
name = "Normal";
price = "3.18";
width = 128;
}])
I want to return B_List full info as var filtered_List = [AnyObject]() where only contains of A_List id number 117, 115, and 18 which look like as below:
filtered_List : Optional([{
URL = "11.jpeg";
categories = "A";
description = "description Crispy.";
height = 128;
id = 18;
likes = "1.00";
name = "Plain";
price = "2.65";
width = 128;
}, {
URL = "11.jpeg";
categories = "B";
description = "Puff";
height = 128;
id = 115;
likes = "1.00";
name = "Mini Puff";
price = "2.12";
width = 128;
}, {
URL = "168.jpeg";
categories = "C";
description = "description YYY";
height = 128;
id = 117;
likes = "1.00";
name = "Normal";
price = "3.18";
width = 128;
}])
I have tried few code and read tutorial in youtube, but unfortunately did not find any solution and it limited to swift2 sample.
Currently, my code tried as below:
var filtered_List = [AnyObject]()
let fullrList = B_List?.map{$0["id"] as! String}.map{_ in A_List}
filtered_List.append(fullrList as AnyObject )
print("result :\(filtered_List)")
Very Appreciated if someone expert can guide or give your solution here.
You should store your desired IDs in a Set, rather than an Array. You're just need a simple filter operation:
let desiredIds: Set = [117, 115, 18]
B_List.filter{ $0["id"].map{ desiredIds.contains($0) } ?? false } as [AnyObject]
Thanks for everyone who reply this topic specially to #Alexander. Here my solutions to share that may not the perfect one as others.
var resultAnyObject = [AnyObject]()
var aListIds = [String]()
for i in A_List! {
aListIds.append(i as! String)
}
//#Alexander : thanks for code below:
let desiredIds = aListIds
let fullList = B_List?.filter{ $0["id"].map{desiredIds.contains($0 as! String) } ?? false };
resultAnyObject.append(fullList as AnyObject)
print("Result of filtered_List :\(resultAnyObject)")

Error: Cannot convert array of data to (class)

I'm still rather new to JS and GAS and I'm afraid I don't understand arrays real well yet. Your help is greatly appreciated.
Prior to this script, I have another script that pulls information from a list into a spreadsheet that is formatted to look like an invoice. The user then makes changes to the invoice and saves that changes back again to the exact same line that the data was pulled from. This is simply a way of updating changes to the invoice in a user-friendly format.
When I run my script below, I get an error saying that it "Cannot convert"...a list of the data in the array..." to (class)"...the name of the file.
I'm afraid I don't know enough about array classes to solve this problem. I looked for other questions and answers to this same problem, but if I found one, I didn't understand it well enough to apply it to my situation.
The error is happening on line 133 (oh, so close to running the whole script).
function overwriteInvoice() {
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Invoice");
//start change customer name into customer code
var customerName = sheet.getRange('I2').getValue();
var ccsheet = ss.getSheetByName("CustomerCodes");
var lastRow = ccsheet.getLastRow();
//check how many rows it found
Logger.log("lastRow: " + lastRow);
var lookUp = ccsheet.getRange(2, 1, lastRow, 3).getValues();
for (nn=0; nn<lookUp.length; ++nn) {
if (lookUp[nn][0] == customerName) {break}
}
var customerCode = lookUp[nn][1];
//check customer code to make sure it is returning correct info.
Logger.log("customerCode: " + customerCode);
//end change customer name into customer code
//start build array
var arrayOfData = [];
arrayOfData[0] = sheet.getRange('G2');//invoiceorquote
arrayOfData[1] = sheet.getRange('C10');//invoicequote number
arrayOfData[2] = sheet.getRange('C9');//date
arrayOfData[3] = customerCode;//customer code DON'T CHANGE THIS
arrayOfData[4] = sheet.getRange('I9'); //joblotcode
arrayOfData[5] = sheet.getRange('J27');//total
arrayOfData[6] = sheet.getRange('L32');//invoice paid
arrayOfData[7] = sheet.getRange('B30');//notes
arrayOfData[8] = sheet.getRange('B13');//area13;
arrayOfData[9] = sheet.getRange('D13');//description13;
arrayOfData[10] = sheet.getRange('I13');//quantity13;
arrayOfData[11] = sheet.getRange('J13');//units13;
arrayOfData[12] = sheet.getRange('K13');//pricePerUnit13;
arrayOfData[13] = sheet.getRange('L13');//subtotal13;
arrayOfData[14] = sheet.getRange('B14');//area14;
arrayOfData[15] = sheet.getRange('D14');//description14;
arrayOfData[16] = sheet.getRange('I14');//quantity14;
arrayOfData[17] = sheet.getRange('J14');//units14;
arrayOfData[18] = sheet.getRange('K14');//pricePerUnit14;
arrayOfData[19] = sheet.getRange('L14');//subtotal14;
arrayOfData[20] = sheet.getRange('B15');//area15;
arrayOfData[21] = sheet.getRange('D15');//description15;
arrayOfData[22] = sheet.getRange('I15');//quantity15;
arrayOfData[23] = sheet.getRange('J15');//units15 ;
arrayOfData[24] = sheet.getRange('K15');//pricePerUnit15 ;
arrayOfData[25] = sheet.getRange('L15');//subtotal15 ;
arrayOfData[26] = sheet.getRange('B16');//area16 ;
arrayOfData[27] = sheet.getRange('D16');//description16 ;
arrayOfData[28] = sheet.getRange('I16');//quantity16 ;
arrayOfData[29] = sheet.getRange('J16');//units16 ;
arrayOfData[30] = sheet.getRange('K16');//pricePerUnit16 ;
arrayOfData[31] = sheet.getRange('L16');//subtotal16 ;
arrayOfData[32] = sheet.getRange('B17');//area17 ;
arrayOfData[33] = sheet.getRange('D17');//description17 ;
arrayOfData[34] = sheet.getRange('I17');//quantity17 ;
arrayOfData[35] = sheet.getRange('J17');//units17 ;
arrayOfData[36] = sheet.getRange('K17');//pricePerUnit17 ;
arrayOfData[37] = sheet.getRange('L17');//subtotal17 ;
arrayOfData[38] = sheet.getRange('B18');//area18 ;
arrayOfData[39] = sheet.getRange('D18');//description18 ;
arrayOfData[40] = sheet.getRange('I18');//quantity18 ;
arrayOfData[41] = sheet.getRange('J18');//units18 ;
arrayOfData[42] = sheet.getRange('K18');//pricePerUnit18 ;
arrayOfData[43] = sheet.getRange('L18');//subtotal18 ;
arrayOfData[44] = sheet.getRange('B19');//area19 ;
arrayOfData[45] = sheet.getRange('D19');//description19 ;
arrayOfData[46] = sheet.getRange('I19');//quantity19 ;
arrayOfData[47] = sheet.getRange('J19');//units19 ;
arrayOfData[48] = sheet.getRange('K19');//pricePerUnit19 ;
arrayOfData[49] = sheet.getRange('L19');//subtotal19 ;
arrayOfData[50] = sheet.getRange('B20');//area20 ;
arrayOfData[51] = sheet.getRange('D20');//description20 ;
arrayOfData[52] = sheet.getRange('I20');//quantity20 ;
arrayOfData[53] = sheet.getRange('J20');//units20 ;
arrayOfData[54] = sheet.getRange('K20');//pricePerUnit20 ;
arrayOfData[55] = sheet.getRange('L20');//subtotal20 ;
arrayOfData[56] = sheet.getRange('B21');//area21 ;
arrayOfData[57] = sheet.getRange('D21');//description21 ;
arrayOfData[58] = sheet.getRange('I21');//quantity21 ;
arrayOfData[59] = sheet.getRange('J21');//units21 ;
arrayOfData[60] = sheet.getRange('K21');//pricePerUnit21 ;
arrayOfData[61] = sheet.getRange('L21');//subtotal21 ;
arrayOfData[62] = sheet.getRange('B22');//area22 ;
arrayOfData[63] = sheet.getRange('D22');//description22 ;
arrayOfData[64] = sheet.getRange('I22');//quantity22 ;
arrayOfData[65] = sheet.getRange('J22');//units22 ;
arrayOfData[66] = sheet.getRange('K22');//pricePerUnit22 ;
arrayOfData[67] = sheet.getRange('L22');//subtotal22 ;
arrayOfData[68] = sheet.getRange('B23');//area23 ;
arrayOfData[69] = sheet.getRange('D23');//description23 ;
arrayOfData[70] = sheet.getRange('I23');//quantity23 ;
arrayOfData[71] = sheet.getRange('J23');//units23 ;
arrayOfData[72] = sheet.getRange('K23');//pricePerUnit23 ;
arrayOfData[73] = sheet.getRange('L23');//subtotal23 ;
arrayOfData[74] = sheet.getRange('B24');//area24 ;
arrayOfData[75] = sheet.getRange('D24');//description24 ;
arrayOfData[76] = sheet.getRange('I24');//quantity24 ;
arrayOfData[77] = sheet.getRange('J24');//units24 ;
arrayOfData[78] = sheet.getRange('K24');//pricePerUnit24 ;
arrayOfData[79] = sheet.getRange('L24');//subtotal24 ;
//end build array
//start find correct row
var searchFor = sheet.getRange("C10").getValue();
var invoiceRecord = ss.getSheetByName("InvoiceRecord");
var lastRow = invoiceRecord.getLastRow();
//verify last row
Logger.log("lastRow: " + lastRow);
//create an array of values to search
var searchArea = invoiceRecord.getRange(4, 1, lastRow, 4).getValues();
//start search the array
for (jj=0; jj<searchArea.length; ++jj) {
if (searchArea[jj][1]==searchFor) {break};
}
var copyToRow = searchArea[jj];
//end find the correct row
//ERROR!
invoiceRecord.getRange(copyToRow, 1, 1, arrayOfData.length).setValues(arrayOfData);
//ERROR!
ui.alert('Invoice Changes Saved', ui.ButtonSet.OK);
}
Thank you so much for your help.
Update
I am so frustrated by this problem that I decided to take a different tact to narrow down the cause. I removed the array entirely and assigned each value to a variable in order to see if the array is the problem. Apparently, it is not. The results when I run this code now say error: "Cannot convert NaN to (class). (line 140, file "OverwriteExistingInvoice")"
function overwriteInvoice() {
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Invoice");
//start change customer name into customer code
var customerName = sheet.getRange('I2').getValue();
var ccsheet = ss.getSheetByName("CustomerCodes");
var lastRow = ccsheet.getLastRow();
//check how many rows it found
Logger.log("lastRow: " + lastRow);
var lookUp = ccsheet.getRange(2, 1, lastRow-2, 3).getValues();
var nn=0
for (nn=0; nn<lookUp.length; ++nn) {
if (lookUp[nn][0] == customerName) {break}
}
var customerCode = lookUp[nn][1];
//check customer code to make sure it is returning correct info.
Logger.log("customerCode: " + customerCode);
//end change customer name into customer code
//start build array
var column0 = sheet.getRange('G2').getValue();//invoiceorquote
var column1 = sheet.getRange('C10').getValue();//invoicequote number
var column2 = sheet.getRange('C9').getValue();//date
var column3 = customerCode;//customer code DON'T CHANGE THIS
var column4 = sheet.getRange('I9').getValue(); //joblotcode
var column5 = sheet.getRange('J27').getValue();//total
var column6 = sheet.getRange('L32').getValue();//invoice paid
var column7 = sheet.getRange('B30').getValue();//notes
var column8 = sheet.getRange('B13').getValue();//area13;
var column9 = sheet.getRange('D13').getValue();//description13;
var column10 = sheet.getRange('I13').getValue();//quantity13;
var column11 = sheet.getRange('J13').getValue();//units13;
var column12 = sheet.getRange('K13').getValue();//pricePerUnit13;
var column13 = sheet.getRange('L13').getValue();//subtotal13;
var column14 = sheet.getRange('B14').getValue();//area14;
var column15 = sheet.getRange('D14').getValue();//description14;
var column16 = sheet.getRange('I14').getValue();//quantity14;
var column17 = sheet.getRange('J14').getValue();//units14;
var column18 = sheet.getRange('K14').getValue();//pricePerUnit14;
var column19 = sheet.getRange('L14').getValue();//subtotal14;
var column20 = sheet.getRange('B15').getValue();//area15;
var column21 = sheet.getRange('D15').getValue();//description15;
var column22 = sheet.getRange('I15').getValue();//quantity15;
var column23 = sheet.getRange('J15').getValue();//units15 ;
var column24 = sheet.getRange('K15').getValue();//pricePerUnit15 ;
var column25 = sheet.getRange('L15').getValue();//subtotal15 ;
var column26 = sheet.getRange('B16').getValue();//area16 ;
var column27 = sheet.getRange('D16').getValue();//description16 ;
var column28 = sheet.getRange('I16').getValue();//quantity16 ;
var column29 = sheet.getRange('J16').getValue();//units16 ;
var column30 = sheet.getRange('K16').getValue();//pricePerUnit16 ;
var column31 = sheet.getRange('L16').getValue();//subtotal16 ;
var column32 = sheet.getRange('B17').getValue();//area17 ;
var column33 = sheet.getRange('D17').getValue();//description17 ;
var column34 = sheet.getRange('I17').getValue();//quantity17 ;
var column35 = sheet.getRange('J17').getValue();//units17 ;
var column36 = sheet.getRange('K17').getValue();//pricePerUnit17 ;
var column37 = sheet.getRange('L17').getValue();//subtotal17 ;
var column38 = sheet.getRange('B18').getValue();//area18 ;
var column39 = sheet.getRange('D18').getValue();//description18 ;
var column40 = sheet.getRange('I18').getValue();//quantity18 ;
var column41 = sheet.getRange('J18').getValue();//units18 ;
var column42 = sheet.getRange('K18').getValue();//pricePerUnit18 ;
var column43 = sheet.getRange('L18').getValue();//subtotal18 ;
var column44 = sheet.getRange('B19').getValue();//area19 ;
var column45 = sheet.getRange('D19').getValue();//description19 ;
var column46 = sheet.getRange('I19').getValue();//quantity19 ;
var column47 = sheet.getRange('J19').getValue();//units19 ;
var column48 = sheet.getRange('K19').getValue();//pricePerUnit19 ;
var column49 = sheet.getRange('L19').getValue();//subtotal19 ;
var column50 = sheet.getRange('B20').getValue();//area20 ;
var column51 = sheet.getRange('D20').getValue();//description20 ;
var column52 = sheet.getRange('I20').getValue();//quantity20 ;
var column53 = sheet.getRange('J20').getValue();//units20 ;
var column54 = sheet.getRange('K20').getValue();//pricePerUnit20 ;
var column55 = sheet.getRange('L20').getValue();//subtotal20 ;
var column56 = sheet.getRange('B21').getValue();//area21 ;
var column57 = sheet.getRange('D21').getValue();//description21 ;
var column58 = sheet.getRange('I21').getValue();//quantity21 ;
var column59 = sheet.getRange('J21').getValue();//units21 ;
var column60 = sheet.getRange('K21').getValue();//pricePerUnit21 ;
var column61 = sheet.getRange('L21').getValue();//subtotal21 ;
var column62 = sheet.getRange('B22').getValue();//area22 ;
var column63 = sheet.getRange('D22').getValue();//description22 ;
var column64 = sheet.getRange('I22').getValue();//quantity22 ;
var column65 = sheet.getRange('J22').getValue();//units22 ;
var column66 = sheet.getRange('K22').getValue();//pricePerUnit22 ;
var column67 = sheet.getRange('L22').getValue();//subtotal22 ;
var column68 = sheet.getRange('B23').getValue();//area23 ;
var column69 = sheet.getRange('D23').getValue();//description23 ;
var column70 = sheet.getRange('I23').getValue();//quantity23 ;
var column71 = sheet.getRange('J23').getValue();//units23 ;
var column72 = sheet.getRange('K23').getValue();//pricePerUnit23 ;
var column73 = sheet.getRange('L23').getValue();//subtotal23 ;
var column74 = sheet.getRange('B24').getValue();//area24 ;
var column75 = sheet.getRange('D24').getValue();//description24 ;
var column76 = sheet.getRange('I24').getValue();//quantity24 ;
var column77 = sheet.getRange('J24').getValue();//units24 ;
var column78 = sheet.getRange('K24').getValue();//pricePerUnit24 ;
var column79 = sheet.getRange('L24').getValue();//subtotal24 ;
//end build array
//start find correct row
var searchFor = sheet.getRange("C10").getValue();
var invoiceRecord = ss.getSheetByName("InvoiceRecord");
var lastRow = invoiceRecord.getLastRow();
//verify last row
Logger.log("lastRow: " + lastRow);
//create an array of values to search
var searchArea = invoiceRecord.getRange(4, 1, lastRow, 4).getValues();
//start search the array
var jj=0
for (jj=0; jj<searchArea.length; ++jj) {
if (searchArea[jj][1]==searchFor) {break};
}
Logger.log('jj value: ' + jj);
var copyToRow = searchArea[jj];
Logger.log('copyToRow: ' + copyToRow);
//end find correct row
//start copy over same entry
//error on next line
invoiceRecord.getRange(copyToRow-1, 1).setValue(column0);
//error on above line
ui.alert('Invoice Changes Saved', ui.ButtonSet.OK);
}
I really appreciate all the help thus far. I am about to tear my hair out!
UPDATE
This is the code that finally worked correctly.
function overwriteInvoice() {
var ui = SpreadsheetApp.getUi();
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Invoice");
//start change customer name into customer code
var customerName = sheet.getRange('I2').getValue();
var ccsheet = ss.getSheetByName("CustomerCodes");
var lastRow = ccsheet.getLastRow();
//check how many rows it found
Logger.log("lastRow: " + lastRow);
var lookUp = ccsheet.getRange(2, 1, lastRow-2, 3).getValues();
var nn=0
for (nn=0; nn<lookUp.length; ++nn) {
if (lookUp[nn][0] == customerName) {break}
}
var customerCode = lookUp[nn][1];
//check customer code to make sure it is returning correct info.
Logger.log("customerCode: " + customerCode);
//end change customer name into customer code
//start build array
var arrayOfData = [];
arrayOfData[0] = sheet.getRange('G2').getValue();//invoiceorquote
arrayOfData[1] = sheet.getRange('C10').getValue();//invoicequote number
arrayOfData[2] = sheet.getRange('C9').getValue();//date
arrayOfData[3] = customerCode;//customer code DON'T CHANGE THIS
arrayOfData[4] = sheet.getRange('I9').getValue(); //joblotcode
arrayOfData[5] = sheet.getRange('J27').getValue();//total
arrayOfData[6] = sheet.getRange('L32').getValue();//invoice paid
arrayOfData[7] = sheet.getRange('B30').getValue();//notes
arrayOfData[8] = sheet.getRange('B13').getValue();//area13;
arrayOfData[9] = sheet.getRange('D13').getValue();//description13;
arrayOfData[10] = sheet.getRange('I13').getValue();//quantity13;
arrayOfData[11] = sheet.getRange('J13').getValue();//units13;
arrayOfData[12] = sheet.getRange('K13').getValue();//pricePerUnit13;
arrayOfData[13] = sheet.getRange('L13').getValue();//subtotal13;
arrayOfData[14] = sheet.getRange('B14').getValue();//area14;
arrayOfData[15] = sheet.getRange('D14').getValue();//description14;
arrayOfData[16] = sheet.getRange('I14').getValue();//quantity14;
arrayOfData[17] = sheet.getRange('J14').getValue();//units14;
arrayOfData[18] = sheet.getRange('K14').getValue();//pricePerUnit14;
arrayOfData[19] = sheet.getRange('L14').getValue();//subtotal14;
arrayOfData[20] = sheet.getRange('B15').getValue();//area15;
arrayOfData[21] = sheet.getRange('D15').getValue();//description15;
arrayOfData[22] = sheet.getRange('I15').getValue();//quantity15;
arrayOfData[23] = sheet.getRange('J15').getValue();//units15 ;
arrayOfData[24] = sheet.getRange('K15').getValue();//pricePerUnit15 ;
arrayOfData[25] = sheet.getRange('L15').getValue();//subtotal15 ;
arrayOfData[26] = sheet.getRange('B16').getValue();//area16 ;
arrayOfData[27] = sheet.getRange('D16').getValue();//description16 ;
arrayOfData[28] = sheet.getRange('I16').getValue();//quantity16 ;
arrayOfData[29] = sheet.getRange('J16').getValue();//units16 ;
arrayOfData[30] = sheet.getRange('K16').getValue();//pricePerUnit16 ;
arrayOfData[31] = sheet.getRange('L16').getValue();//subtotal16 ;
arrayOfData[32] = sheet.getRange('B17').getValue();//area17 ;
arrayOfData[33] = sheet.getRange('D17').getValue();//description17 ;
arrayOfData[34] = sheet.getRange('I17').getValue();//quantity17 ;
arrayOfData[35] = sheet.getRange('J17').getValue();//units17 ;
arrayOfData[36] = sheet.getRange('K17').getValue();//pricePerUnit17 ;
arrayOfData[37] = sheet.getRange('L17').getValue();//subtotal17 ;
arrayOfData[38] = sheet.getRange('B18').getValue();//area18 ;
arrayOfData[39] = sheet.getRange('D18').getValue();//description18 ;
arrayOfData[40] = sheet.getRange('I18').getValue();//quantity18 ;
arrayOfData[41] = sheet.getRange('J18').getValue();//units18 ;
arrayOfData[42] = sheet.getRange('K18').getValue();//pricePerUnit18 ;
arrayOfData[43] = sheet.getRange('L18').getValue();//subtotal18 ;
arrayOfData[44] = sheet.getRange('B19').getValue();//area19 ;
arrayOfData[45] = sheet.getRange('D19').getValue();//description19 ;
arrayOfData[46] = sheet.getRange('I19').getValue();//quantity19 ;
arrayOfData[47] = sheet.getRange('J19').getValue();//units19 ;
arrayOfData[48] = sheet.getRange('K19').getValue();//pricePerUnit19 ;
arrayOfData[49] = sheet.getRange('L19').getValue();//subtotal19 ;
arrayOfData[50] = sheet.getRange('B20').getValue();//area20 ;
arrayOfData[51] = sheet.getRange('D20').getValue();//description20 ;
arrayOfData[52] = sheet.getRange('I20').getValue();//quantity20 ;
arrayOfData[53] = sheet.getRange('J20').getValue();//units20 ;
arrayOfData[54] = sheet.getRange('K20').getValue();//pricePerUnit20 ;
arrayOfData[55] = sheet.getRange('L20').getValue();//subtotal20 ;
arrayOfData[56] = sheet.getRange('B21').getValue();//area21 ;
arrayOfData[57] = sheet.getRange('D21').getValue();//description21 ;
arrayOfData[58] = sheet.getRange('I21').getValue();//quantity21 ;
arrayOfData[59] = sheet.getRange('J21').getValue();//units21 ;
arrayOfData[60] = sheet.getRange('K21').getValue();//pricePerUnit21 ;
arrayOfData[61] = sheet.getRange('L21').getValue();//subtotal21 ;
arrayOfData[62] = sheet.getRange('B22').getValue();//area22 ;
arrayOfData[63] = sheet.getRange('D22').getValue();//description22 ;
arrayOfData[64] = sheet.getRange('I22').getValue();//quantity22 ;
arrayOfData[65] = sheet.getRange('J22').getValue();//units22 ;
arrayOfData[66] = sheet.getRange('K22').getValue();//pricePerUnit22 ;
arrayOfData[67] = sheet.getRange('L22').getValue();//subtotal22 ;
arrayOfData[68] = sheet.getRange('B23').getValue();//area23 ;
arrayOfData[69] = sheet.getRange('D23').getValue();//description23 ;
arrayOfData[70] = sheet.getRange('I23').getValue();//quantity23 ;
arrayOfData[71] = sheet.getRange('J23').getValue();//units23 ;
arrayOfData[72] = sheet.getRange('K23').getValue();//pricePerUnit23 ;
arrayOfData[73] = sheet.getRange('L23').getValue();//subtotal23 ;
arrayOfData[74] = sheet.getRange('B24').getValue();//area24 ;
arrayOfData[75] = sheet.getRange('D24').getValue();//description24 ;
arrayOfData[76] = sheet.getRange('I24').getValue();//quantity24 ;
arrayOfData[77] = sheet.getRange('J24').getValue();//units24 ;
arrayOfData[78] = sheet.getRange('K24').getValue();//pricePerUnit24 ;
arrayOfData[79] = sheet.getRange('L24').getValue();//subtotal24 ;
//end build array
//start find correct row
var searchFor = sheet.getRange("C10").getValue();
var invoiceRecord = ss.getSheetByName("InvoiceRecord");
var lastRow = invoiceRecord.getLastRow();
//verify last row
Logger.log("lastRow: " + lastRow);
//create an array of values to search
var searchArea = invoiceRecord.getRange(4, 1, lastRow, 4).getValues();
//start search the array
var jj=0
for (jj=0; jj<searchArea.length; ++jj) {
if (searchArea[jj][1]==searchFor) {break};
}
Logger.log('jj value: ' + jj);
var copyToRow = jj+4;
Logger.log('copyToRow: ' + copyToRow);
//end find correct row
//start copy over the same entry
var outerArray = [];
outerArray.push(arrayOfData);
invoiceRecord.getRange(copyToRow, 1, 1, 80).setValues(outerArray);
ui.alert('Invoice Changes Saved', ui.ButtonSet.OK);
}
Add the getValue() method to all of the lines with:
arrayOfData[x] = sheet.getRange('XX');//What to get
Right now, a range object is being put into the array, and not a value.
Should be:
arrayOfData[x] = sheet.getRange('XX').getValue();//Note
Create an outer array, and put arrayOfData into it:
var outerArray = [];
outerArray.push(arrayOfData);
//getRange(Start row, start column, number of rows, number of columns)
invoiceRecord.getRange(copyToRow, 1, outerArray.length, outerArray[0].length)
.setValues(outerArray);
The setValues() method must have a two dimensional array. If this is for just one row of data, then there will only be one inner array.

TYPO3 Formhandler finisher does not write to database

After the TYPO3 (6.1.7) website of a customer has gone online, the Formhandler forms do not work correctly anymore. They do send an email, but it seems that they do not execute the Finisher_DB for writing into the database anymore.
The TypoScript settings look like this:
plugin.Tx_Formhandler.settings {
debug = 0
# GENERAL CONFIGURATION
name = Default
addErrorAnchors = 1
formValuesPrefix = formhandler
fillValueMarkersBeforeLangMarkers = 1
# ERRORS LAYOUT
singleErrorTemplate {
totalWrap = <div>|</div>
singleWrap = <span class="error">|</span><br />
}
errorListTemplate {
totalWrap = <ul>|</ul>
singleWrap = <li class="error">|</li>
}
validators {
1.class = Tx_Formhandler_Validator_Default
1.config {
fieldConf {
wish.errorCheck.1 = required
alternative.errorCheck.1 = required
firstname.errorCheck.1 = required
surname.errorCheck.1 = required
nationality.errorCheck.1 = required
dateofbirth.errorCheck.1 = required
phone.errorCheck.1 = required
email.errorCheck.1 = required
street.errorCheck.1 = required
zip.errorCheck.1 = required
city.errorCheck.1 = required
country.errorCheck.1 = required
}
}
}
# Finishers configuration
finishers {
1.class = Tx_Formhandler_Finisher_Mail
1.config {
checkBinaryCrLf = registrationMessagePlain, registrationMessageHtml
limitMailsToUser = 10
admin {
}
user {
}
}
2.class = Tx_Formhandler_Finisher_DB
2.config{
table = tx_chilifhregistration
key = uid
fields {
timeslot = Sommerplatz
timeslot_july.mapping = timeslotSummerJuly
timeslot_august.mapping = timeslotSummerAugust
timeslot_september.mapping = timeslotSummerSeptember
wish.mapping = wish
wishcategory11.mapping = wishCategory11
wishcategory19.mapping = wishCategory19
wishcategory22.mapping = wishCategory22
wishcategorydb.mapping = wishCategoryDb
alternative.mapping = alternative
alternativecategory11.mapping = alternativeCategory11
alternativecategory19.mapping = alternativeCategory19
alternativecategory22.mapping = alternativeCategory22
alternativecategorydb.mapping = alternativeCategoryDb
salutation.mapping = salutation
firstname.mapping = firstname
surname.mapping = surname
nationality.mapping = nationality
dateofbirth.mapping = dateofbirth
phone.mapping = phone
email.mapping = email
street.mapping = street
zip.mapping = zip
city.mapping = city
country.mapping = country
salutation2.mapping = salutation2
firstname2.mapping = firstname2
surname2.mapping = surname2
nationality2.mapping = nationality2
dateofbirth2.mapping = dateofbirth2
phone2.mapping = phone2
email2.mapping = email2
street2.mapping = street2
zip2.mapping = zip2
city2.mapping = city2
country2.mapping = country2
}
}
}
}
What could be the problem?
You should better use the predef-definition-style for forms. This will save you trouble with multiple forms and is a cleaner implementation.
plugin.Tx_Formhandler.settings.predef.yourformularname { ...config... }
You can find a bunch of examples on the offical site/examples
I assume that your admin and user mail-config is only empty because you won´t post any customerinformation?
Did the form work if you fill in every single field?
In my own usecases all field i map with the finisher are required, maybe you should set a ...IfEmpty-option for non-require fields.
Here are the available ifEmpty-options.

Resources