-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
23Questions
-
26Replies
-
- bca321
- March 24, 2009
- Like
- 0
- Continue reading or reply
Apex loop Error
Hi
I have a text file. I tried to import text file
data to salesforce custom object. One file has several pages. each page
has same format. I tried to import one page for may object. It's
working. Now I want to attach several pages for my text file and import
all "RECEIPS" parts for my same object. I want to import only "RECEIPT"
data for an object. I took "RECEIPTS" and "TOTAL " words as a flags. I
tried search "RECEIPTS" word and if found it insert data. Again if
found "TOTAL" word continue. If found "TOTAL" i want to go to loop
again find "RECEIPTS" word and again insert data. How can I do that one.
I think we can search like this: Boolean IsRECEIPTS = false;
Document d = [SELECT id, Body from Document where id = '01580000000Uxou'];
Blob bodyBlob = d.Body;
String bodyStr = bodyBlob.toString();
String[]lines = bodyStr.split('\\n');
//System.debug('lines' + lines);
//Boolean matchFound = m.find();
String searchfor = 'RECEIPTS';
Boolean matchFound = false;
String input ='';
for (integer i = 0; i < lines.size(); i++) {
input = lines[i];
if (input.contains(searchfor)) {
input = input.replace(searchfor,'');
}
//output += input + '<br />';
String regex =
'\\s*(\\d\\d\\s\\w\\w\\w\\s\\d\\d)\\s*(\\d+)\\s*(\\d+)\\s*(\\d*\\,*\\d+.\\d*)\\s*(\\d+)\\s*(\\d*\\,*\\d+.\\d*)\\s*';
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
matchFound = m.find();
output += matchFound ;
if(matchFound){
pDueDate = m.group(1);
FileNumber = double.valueOf(m.group(2));
DebitItems = double.valueOf(m.group(3));
DebitAmount = decimal.valueOf(m.group(4).replace(',',''));
CreditItems = double.valueOf(m.group(5));
String aa = m.group(6).replace(',','');
CreditAmount = decimal.valueOf(aa.replace('"',''));
output += pDueDate + ' ' + FileNumber + ' ' + DebitItems + ' ' +
DebitAmount + ' ' + CreditItems + ' ' + CreditAmount;
Receipt__c newReceipt = new Receipt__c();
newReceipt.Due_Date_del__c = customDate(pDueDate);
newReceipt.File_Number__c = FileNumber;
newReceipt.Debit_Items__c = DebitItems;
newReceipt.Debit_Amount__c = DebitAmount;
newReceipt.Credit_Items__c = CreditItems;
newReceipt.Credit_Amount__c = CreditAmount;
insert newReceipt;
newReceipt = null;
output += '\n<br>';
}//if
if(input.contains('TOTAL')){
continue;
}
}
return output;
}
}
-
- bca321
- March 16, 2009
- Like
- 0
- Continue reading or reply
Currency error
Hi,
I tried to convert currency value String to decimal type.
String a = '';
Decimal DebitAmount;
a='';
if((a<>null)&&(a<>'')){
DebitAmount = decimal.valueOf(a);
}
system.debug('\n\n String a='+a);
system.debug('\n\n Decimal DebitAmount='+DebitAmount);
And this value I insert to salesforce.
My regular expersion is (\\d*\\,*\\d+.\\d*)
DebitAmount = decimal.valueOf(m.group(1).replace(',',''));
newReceipt.Debit_Amount__c = DebitAmount;
insert newReceipt;
Currency ex: 66,967.78 But after insert the salesforce this value convert to as a rounded value. (66,968). But I want to actual value. Not the rounded value. How can I do it.
-
- bca321
- March 15, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 11, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 11, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 10, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 10, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 09, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 09, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 04, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 04, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 04, 2009
- Like
- 0
- Continue reading or reply
Apex
-
- bca321
- March 03, 2009
- Like
- 0
- Continue reading or reply
Date type
Hi.
My date method is
Date submitDate;
string year = '';
string month = '';
string day = '';
string stringDate = year + '-' + month + '-' + day;
Date SubmitDate = date.valueOf(stringDate);
But still error. help me
-
- bca321
- March 03, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 03, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- March 02, 2009
- Like
- 0
- Continue reading or reply
How to skip line
Hi,
I have text file and I want read data from 5th line. How can I skip line 1 - 5? and also empty lines I want to skip. Pl's explain me.
-
- bca321
- March 01, 2009
- Like
- 0
- Continue reading or reply
Apex code error
Hi,
My date field type is Date. date patern is yy-mm-dd.
String year = '';
String month = '';String day =
'';string stringDate = year + '' + month + '' + day;Date DueDate = date.valueOf(stringDate);
my code is here. but still error. can you pl's tel me how to write code. and also I want to write regular expression for that date field.
-
- bca321
- February 26, 2009
- Like
- 0
- Continue reading or reply
-
- bca321
- February 24, 2009
- Like
- 0
- Continue reading or reply
How to use "RegExp"
Hi,
I want to know How to add the "regExp" for Apex code. I have list of data as a .txt file. I want to split that data put a array.
Help me.
-
- bca321
- February 18, 2009
- Like
- 0
- Continue reading or reply
- bca321
- March 11, 2009
- Like
- 0
- Continue reading or reply
- bca321
- March 10, 2009
- Like
- 0
- Continue reading or reply
- bca321
- March 09, 2009
- Like
- 0
- Continue reading or reply
- bca321
- March 09, 2009
- Like
- 0
- Continue reading or reply
- bca321
- March 04, 2009
- Like
- 0
- Continue reading or reply
Apex
- bca321
- March 03, 2009
- Like
- 0
- Continue reading or reply
Date type
Hi.
My date method is
Date submitDate;
string year = '';
string month = '';
string day = '';
string stringDate = year + '-' + month + '-' + day;
Date SubmitDate = date.valueOf(stringDate);
But still error. help me
- bca321
- March 03, 2009
- Like
- 0
- Continue reading or reply
- bca321
- March 03, 2009
- Like
- 0
- Continue reading or reply
How to skip line
Hi,
I have text file and I want read data from 5th line. How can I skip line 1 - 5? and also empty lines I want to skip. Pl's explain me.
- bca321
- March 01, 2009
- Like
- 0
- Continue reading or reply
Apex code error
Hi,
My date field type is Date. date patern is yy-mm-dd.
String year = '';
String month = '';String day =
'';string stringDate = year + '' + month + '' + day;Date DueDate = date.valueOf(stringDate);
my code is here. but still error. can you pl's tel me how to write code. and also I want to write regular expression for that date field.
- bca321
- February 26, 2009
- Like
- 0
- Continue reading or reply
Convert a Picklist value to a Double value
Is there any functionnality ( like toString) to covnert My picklist values (String) to a double ( Like parseFloat in Javascript).
Thank you
- Mig
- February 05, 2008
- Like
- 0
- Continue reading or reply