Clob field not working in BEFORE INSERT trigger
Hello, everyone. I am trying to create a before insert trigger for a table (10g). I would like to create a value for a table field based on the xml query from a clob field. The table looks like this:
SQL> desc lac_costing_upload
Name Type Nullable Default Comments
UPLOAD_ID NUMBER Y
EMP_NUM VARCHAR2(20)
UPLOAD_DATE DATE Y
YEAR_MONTH VARCHAR2(10) Y
UPLOAD_TEXT CLOB Y
The trigger code looks like this:
create or replace trigger lac_cst_upl_yr_month
before insert on lac_costing_upload
for each row
declare
l_month varchar2(20);
l_year varchar2(20);
l_error_msg varchar2(255);
begin
SELECT XMLTYPE (:old.upload_text).EXTRACT('Oracle_Extract/Year/text()').getstringval() Extr_Year
, XMLTYPE (:old.upload_text).EXTRACT('Oracle_Extract/Month/text()').getstringval() Extr_Month
into l_year
, l_month
FROM dual;
:new.year_month := l_year || '.'
|| substr(l_month, 1, 3)
exception
when others then
l_error_msg := substr(sqlerrm, 1, 10);
:new.year_month := l_error_msg;
end lac_cst_upl_yr_month;
Here is a sample insert statement:
insert into lac_costing_upload lcu values(2006, '008925', sysdate, null
, '<Oracle_Extract>' || chr(10)
|| ' <Emp_Num>05417</Emp_Num>' || chr(10)
|| ' <Emp_Name>Fitzgerald</Emp_Name>' || chr(10)
|| ' <Year>2007</Year>' || chr(10)
|| ' <Month>May</Month>' || chr(10)
|| ' <Vehicle>1330</Vehicle>' || chr(10)
|| '</Oracle_Extract>'
My hope was to see '2007.May' in the year_month field. However, I'm getting 'ORA-06502:' instead. It looks like the value of :old.upload_text is null in the trigger.
Can anyone tell me what I'm doing wrong?
Thanks for any help.
--Dave
That's probably a really dumb error, but I don't work much with triggers.
It's working now.
Thanks for your help.
--Dave
Similar Messages
-
INSERTstatement is not working if there is a before insert trigger
INSERTstatement is not working if there is a before insert trigger on that table. That trigger contains an insert to another table which having the main table reference.
Let us say, for example there a table named 'EMP_DEPT' and there is a before insert trigger on this table.
In this trigger inserting a record in to another table named 'AUDIT_EMP' and in this table using EMP_Dept primary key as foreign key.
Table EMP_DEPT is having the below columns:
EMP_DEPT_SYS_ID
EMP_DEPT_NO
DEP_NAME etc..
Table AUDIT_EMP is having the below columns:
AUDIT_EMP_SYS_ID
EMP_DEPT_SYS_ID
AUDIT_NO etc..
the code in the trigger is
INSERT INTO audit_emp
(audit_emp_sys_id, emp_dept_sys_id, audit_no
VALUES (audit_emp.NEXTVAL, :new EMP_DEPT_SYS_ID, '1101'
Now when you execute the insert query like:
INSERT INTO emp_dept
(emp_dept_sys_id, emp_dept_no, dep_name
VALUES (EMP_DEPT.nextval, 1001, 'Dep-1'
It is giving the error saying 'Integrity constraint error, parent key not found' from the trigger.
But, when you modify the above insert query like the below then it is working.
INSERT INTO emp_dept
(emp_dept_sys_id, emp_dept_no, dep_name
SELECT EMP_DEPT.nextval, 1001, 'Dep-1'
FROM DUAL;
I am using Oracle 10g.
Why the insert into values is not working. Is there any commit transaction sequence change? Any idea please?
Edited by: user6475632 on Sep 16, 2009 7:08 AMObviously the code you posted can not work.
You are inserting the detail record (the audit record) before the master record, where it should have been after. IMO, you should fire the trigger AFTER INSERT for each row.
If that still doesn't work, you need to change the foreign key constraint into a deferred constraint, which is evaluated at commit, instead of immediately. The SQL reference manual has further info on this.
'Oracle 10g' is considered a marketing label here, not a -4 digit- version.
Sybrand Bakker
Senior Oracle DBA -
Problem while using Before insert Trigger
Hello everybody,
I am using 9.2.0.4.0 XMLDB..
The problem occurs while using the before insert trigger shown below to convert a CLOB(:new.file_clob) to XMLTYPE(:new.file_xml). The trigger is on a table with file_clob and file_xml as columns. file_xml column is based on a registered schema.
The trigger is:
Create or replace trigger po_2_demo_xml_tab_trg
before insert on po_2_demo_xml_tab
FOR EACH ROW
-- Step 1:to convert CLOB to XMLtype and store it
--in :new.file_xml .
:new.file_xml := xmltype(:new.file_clob);
-- Step 2:to verify if :new.file_xml has been created
dbms_output.put_line(:new.file_xml.extract('/PurchaseOrder/PONum/text()').getStringVal());
end;
If u insert a valid xml file, u can see the PONum value on dbms output(Step 2 of the trigger works). u also get the "1 row inserted" message.
Surpisingly, if u query on the table it shows that the file_xml column is null! For some reason, the value of :new.file_xml in the before insert trigger is not being retained in the table.
Has anybody encountered this before? Do I have to apply any patch?
Appreciate any help in this regard.
Thanks,
Partha.sorry! I just noticed.. the trace file does show an error, but the error is while creating the table itself.
Please see the segment from trace file below:
The following statements encountered a error during parse:
create table po_2_demo_clob_xml_tab
file_clob CLOB,
file_xml xmltype
)xmltype column file_xml
XMLSCHEMA "http://Friday/PO_2.xsd"
ELEMENT "PurchaseOrder";
XCTEND rlbk=0,
Error encountered: ORA-00911
But, inspite of this I am able to insert a xml file into file_xml using a sql statement. But the before insert trigger does not retain :new values.
Appreciate any comments.
Thanks,
Partha. -
Problem determining if id is present in BEFORE INSERT trigger
Hi,
I have written a BEFORE INSERT trigger in which I am trying to determine whether or not an id (primary key ) has been submitted as part of the insert. The reason for this is that in my application there are two cases in which the trigger will be called, 1) when the id has been previously obtained from a sequence and passed in, and 2) when an id needs to be 'automatically' generated from within the trigger'. (two subsystems which work differently talk to the database in different ways)
this is the key part of the trigger code:
CREATE OR REPLACE TRIGGER trg_submissions_seq_id
BEFORE INSERT on submissions
FOR EACH ROW
BEGIN
if :new.id IS NULL THEN
select seq_submissions_id.nextval INTO :new.id FROM DUAL;
end if;
....more code here
END;
I think this is correct. Can someone confirm this.
However the behaviour I see is that in case 1 the id is increased twice , once when it is obtained from the sequence , and then again in the trigger... despite the condition I put in.
If anyone can shed any light on this behaviour I would be grateful.
MarkThis trigger (at least what you've posted of it) won't increment the sequence if Rails passes in the ID column. If you're always seeing the sequence incremented twice, I would tend to wager that either Rails is calling the nextval function twice or that it is not passing in an ID. Of course, since Oracle sequence-generated values are not gap-free, presumably this is just a cosmetic issue, not a functionality issue.
As a general matter, I'd suggest not using ID as a column name for a table. In addition to being a poor naming convention, ID is a reserved word.
Justin -
I download the new IOS7 in my iPad beeing in the usa And where I come back to my country appears me again to upad te my iPad of ferina the IOS 7. I did it my iPhone And is not working as before.what i must do
I'm sorry, but I do not understand what you are asking or saying. Perhaps you could clarify a little bit.
-
AT END OF for char field not working
Hi all,
AT END OF (char field) not working,
I sorted the itab and also avoid the stars(*) problem also, but its not working.
Thanks in advance.
Edited by: Vijay Babu Dudla on Jan 28, 2009 11:01 PMHi, Niranjan
Test the following Sample Code it will solve out your Problem,
" This is not working properly right now.
TYPES: BEGIN OF t_name,
name1(10), " if You Change Cut the Name2 from the 2nd line and past it up to the Name one will work fine
name2(10),
amount1 TYPE p,
amount2 TYPE p,
END OF t_name.
DATA: it1_sum TYPE STANDARD TABLE OF t_name WITH HEADER LINE,
wa_it1_sum TYPE t_name,
it2_sum TYPE STANDARD TABLE OF t_name WITH HEADER LINE,
wa_it2_sum TYPE t_name.
wa_it1_sum-name1 = 'AAAAAA'.
wa_it1_sum-name2 = 'AAAAAA'.
wa_it1_sum-amount1 = 500.
wa_it1_sum-amount2 = 200.
APPEND wa_it1_sum TO it1_sum.
wa_it1_sum-name1 = 'AAAAAA'.
wa_it1_sum-name2 = 'AAAAAA'.
wa_it1_sum-amount1 = 500.
wa_it1_sum-amount2 = 200.
APPEND wa_it1_sum TO it1_sum.
wa_it1_sum-name1 = 'BBBBBB'.
wa_it1_sum-name2 = 'AAAAAA'.
wa_it1_sum-amount1 = 100.
wa_it1_sum-amount2 = 200.
APPEND wa_it1_sum TO it1_sum.
wa_it1_sum-name1 = 'AAAAAA'.
wa_it1_sum-name2 = 'AAAAAA'.
wa_it1_sum-amount1 = 500.
wa_it1_sum-amount2 = 10000.
APPEND wa_it1_sum TO it1_sum.
wa_it1_sum-name1 = 'BBBBBB'.
wa_it1_sum-name2 = 'AAAAAA'.
wa_it1_sum-amount1 = 105000.
wa_it1_sum-amount2 = 20500.
APPEND wa_it1_sum TO it1_sum.
wa_it1_sum-name1 = 'BBBBBB'.
wa_it1_sum-name2 = 'AAAAAA'.
wa_it1_sum-amount1 = 21000.
wa_it1_sum-amount2 = 22000.
APPEND wa_it1_sum TO it1_sum.
SORT it1_sum BY name1 name2.
LOOP AT it1_sum INTO wa_it1_sum.
APPEND wa_it1_sum TO it2_sum.
AT END OF name2. " When you will use this in this Condition it will give you wrong Because this row is on number two and
" it is not changing but the Row one is Changing so it will work fine if LEFT MOST
SUM.
wa_it1_sum-name1 = 'End Name 2'.
wa_it1_sum-name2 = 'End Name 2'.
APPEND wa_it1_sum TO it2_sum.
ENDAT.
AT LAST.
SUM.
wa_it1_sum-name1 = 'At Last'.
APPEND wa_it1_sum TO it2_sum.
ENDAT.
ENDLOOP.
Please Reply if need more help about it.
Kind Regards,
Faisal -
After download ios5 my iPhone dose not work like before why?
After download ios5 my iPhone dose not work like before why?
i have iphone 3gsOK this is the issue after download ios5 my phone goes crazy like when i turn on my 3G i can`t call someone and i cant even check my email i don't know why ...so after all this problem i have to turn 3G off and than call to my friend so why it work like this ?
i restore my phone ...i restore as a new phone but still i have the problem .... -
Clob is not working for bulk data files in PL/SQL XML program
Hi Odie,
we took your help to fix the our issue before
"https://forums.oracle.com/forums/thread.jspa?threadID=2238458&tstart=105"
working fine for : program is working for smaller size data.
Issue : now we have problem with the largr size data .
getting the below error:
Arguments
P_dir_name='/tmp'
P_file_name='CCBGO.COLO_CNG.RESPONSES.20120802.00054131826'
Environment will now switch to UTF-8 code-set.
Parts of this log file may not display correctly
as a result. This is an expected behavior.
XML_REPORTS_XENVIRONMENT is :
/apps/applmgr/product/OFDEV/ofdevora/806/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
XENVIRONMENT is set to /apps/applmgr/product/OFDEV/ofdevora/806/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :
American_America.UTF8
stat_low = 8B
stat_high = 0
emsg:was terminated by signal 11
Appreciated for your earlier support.
Kindly suggest .
Many Thanks,
Ramesh.Thanks ALex,
your are true it is concurrent program error ,
but it is working for small amount of data and generating the output and it is not working for larger data.
i have placed the code which i have used kindly suggest where i am going wrong.
i am calling the .rdf through the concurrent program, i've used the below query in RDF
select
BATCHHEADER
,BATCHTRAILER
,RqUID
,Severity
,PmtRefId
,StatusDesc
,ErrorDesc
,AsOfDate
,AsOfTime
,RqUID1
,SPRefId
from table(CL_CXFRFXFH_PKG.rcacknowledgments(:P_dir_name,:P_file_name));
kindly find the below code for the package CL_CXFRFXFH_PKG.
==========================
CREATE OR REPLACE package body APPS.CL_CXFRFXFH_PKG is
function rcacknowledgments (p_directory in varchar2, p_filename in varchar2)
return TRecordTable pipelined
is
nb_rec number := 1;
tmp_xml clob;
tmp_file clob;
rec TRecord;
begin
dbms_lob.createtemporary(tmp_file, true);
tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
rec.BATCHHEADER := regexp_replace(tmp_file, '.*<BATCHHEADER>(.*)</BATCHHEADER>.*', '\1', 1, 1, 'n');
rec.BATCHTRAILER := regexp_replace(tmp_file, '.*<BATCHTRAILER>(.*)</BATCHTRAILER>.*', '\1', 1, 1, 'n');
loop
tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
exit when length(tmp_xml) = 0;
--dbms_output.put_line(tmp_rec);
nb_rec := nb_rec + 1;
select RqUID, Severity, PmtRefId, StatusDesc, ErrorDesc, AsOfDate, AsOfTime, RqUID1, SPRefId
into rec.RqUID
, rec.Severity
, rec.PmtRefId
, rec.StatusDesc
, rec.ErrorDesc
, rec.AsOfDate
, rec.AsOfTime
, rec.RqUID1
, rec.SPRefId
from xmltable(
'/CMA/BankSvcRq' passing xmltype(tmp_xml)
columns RqUID varchar2(3000) path 'RqUID'
, Severity varchar2(3000) path 'XferAddRs/Status/Severity'
, PmtRefId varchar2(3000) path 'XferAddRs/Status/PmtRefId'
, StatusDesc varchar2(3000) path 'XferAddRs/Status/StatusDesc'
, ErrorDesc varchar2(3000) path 'XferAddRs/Status/ErrorDesc'
, AsOfDate varchar2(3000) path 'XferAddRs/Status/AsOfDate'
, AsOfTime varchar2(3000) path 'XferAddRs/Status/AsOfTime'
, RqUID1 varchar2(3000) path 'XferAddRs/RqUID'
, SPRefId varchar2(3000) path 'XferAddRs/SPRefId'
pipe row ( rec );
end loop;
dbms_lob.freetemporary(tmp_file);
return;
end;
end;
============================================
Many Thanks,
Ramesh. -
Calling function in before insert trigger
HELLO,
**TRIGGER IS NOT DISPLAYING THE DATA ACCURATELY**
**PLZ HELP ITS URGENT...**
THE CODE IS BELOW.....
create or replace TRIGGER GENSTUDYID
BEFORE INSERT
ON ER_PATPROT
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
lPatStudyID varchar2(30);
lSiteCode number(10);
lStudyCode number(10);
lpk_patprot Number(10);
lpatprot_enroldt date;
lFK_PER number(20);
lIPADD varchar2(15);
lfk_protocol number(20);
llast_modified_by number;
lgencal_status number;
BEGIN
lSiteCode := :New.fk_site_enrolling;
lStudyCode := :new.fk_study;
lpk_patprot := :new.pk_patprot;
lpatprot_enroldt := :new.patprot_enroldt;
lFK_PER := :new.fk_per;
lIPADD :=NULL;
lPatStudyID:=GenerateStudyID(lSiteCode,lStudyCode,lFK_PER);
IF lPatStudyID IS NOT NULL then
:NEW.patprot_patstdid := lpatstudyid;
END IF;
END;
-----------FUNCTION CODE STARTS
create or replace
function GenerateStudyID (sitecode number,studycode number,pid number) RETURN VARCHAR IS
lfield_name varchar2(10);
lfield_format varchar2(10);
lfield_length number(2);
lfield_deftext varchar2(500);
lparam1 varchar2(30):=sitecode;
lparam2 varchar2(30):=studycode;
lresult varchar2(30);
lstudyid varchar2(30);
lPATPROT_PATSTDID varchar2(20);
CURSOR studyid_def_cur is select field_name, field_format, field_length, field_deftext from bayatree.studyid_definition
where study_code = studycode and site_code=sitecode order by field_seqno;
CURSOR patprot_patstdid_cur is select PATPROT_PATSTDID from eres.er_patprot where fk_study=studycode and fk_per=pid;
BEGIN
lstudyid := NULL;
dbms_output.put_line('studycode: '||studycode);
dbms_output.put_line('pid; '||pid);
FOR disp_studyid in patprot_patstdid_cur
LOOP
lPATPROT_PATSTDID:=disp_studyid.PATPROT_PATSTDID;
dbms_output.put_line('lPATPROT_PATSTDID: '||lPATPROT_PATSTDID);
END LOOP;
IF lPATPROT_PATSTDID IS NULL THEN
OPEN studyid_def_cur;
LOOP
FETCH studyid_def_cur INTO lfield_name, lfield_format, lfield_length, lfield_deftext;
EXIT WHEN studyid_def_cur%NOTFOUND;
lfield_deftext:= replace(lfield_deftext,'param1',lparam1);
lfield_deftext:= replace(lfield_deftext,'param2',lparam2);
if (instr (lfield_deftext, 'select',1) > 0) then
execute immediate lfield_deftext into lresult;
else
execute immediate lfield_deftext;
lresult := null;
end if;
if lfield_format is not null and lresult is not null and lfield_length is not null then
lresult := lpad(lresult, lfield_length, 0);
end if;
if lfield_name is not null and lresult is not null then
lstudyid := lstudyid || lresult;
end if;
END LOOP;
return (lstudyid);
ELSE
lstudyid:=lPATPROT_PATSTDID;
Dbms_output.put_line('Study Id: '||lstudyid);
return (lstudyid);
END IF;
END;Your post is not quiet readable, please include your program in tags, Include sample data and sample output, table and other objects creation and insert scripts.
What error are you getting anyway post the Oracle error code
SS -
Before insert Trigger and SQL Loader
Hi,
I have a table with a BEFOR insert on each row trigger . I am loading the data to that table using sqlloader and I want my trigger to fire for each row. But the trigger is firing only for alternate rows.
body of trigger as follows.
select max(pd_id) into VarVal from <table name> where tar_id=:new.tar_id;
select pd_id+1 into :new.pd_id from dual;
if I remove the first select statement from my trigger , then it is firing for all the rows. But the removel of first select statement will not satisfy my requirements.
So please suggest me how can I achieve this.[url http://forums.oracle.com/forums/thread.jspa?threadID=587783&tstart=0]duplicate thread
-
IDoc string field to JDBC date field - Not working
Hello everyone,
Once again I must ask you something that is keeping me..
I had a interface type RFC ASync to JDBC SQL Server, it was working fine. Then, I was asked to change to a type iDoc ASync to JDBC SQL Server.
At first, it was not a problem, just manual work. But them, I am getting an error.
In the RFC, I had a date field, that was directly related to the date field on the JDBC destination, so the mapping was pretty much straight forward. The SQL INSERT command was working fine on this cenario.
Now, in iDoc, this field was automatically converted to a string, and somehow, PI is not understanding that string has to be mapped to a date field in the JDBC.
Is there any 'workaround' for me to do this?
Thanks!
Ricardo Sancio Lóra
BrazilThe issue here is that somehow, the same SQL insert command that was working, does not work anymore.
This is the SQL command took from RWB log monitor:
INSERT INTO aniversariantes_sap (matricula, nome, nascimento, unidade) VALUES (00000070, 'Ricardo Lora', '19851216', 00000000)
If I run this query on my DB it works.
But, in PI, it's not, here is the error:
Could not execute statement for table/stored proc. "aniversariantes_sap" (structure "ANIVERSARIANTES_SAP") due to com.microsoft.sqlserver.jdbc.SQLServerException: Syntax error converting datetime from character string.
I´ve tried cast() and convert() using mapping 'habilities', but also, does not work. Work if I run in the DB, but not if PI runs it.
Wierd..
Ricardo -
Help for date field not working after upgrade
hi experts,
In our BSP application for a page we had an inputfield (date).
Onvaluehelp for input field we were calling the saphelpdate function.
however after upgrade this functionality is not working properly as no pop up comes after clicking on the icon.
we have upgraded to SPS 16 recently.
please help me.
regards,
Arvind.Hi, I try upper case but nothing happen. This is all my code by far, I hope you can help me:
DATA: BEGIN OF T_PCONT OCCURS 0,
PCONT LIKE ZPSPERMISOS-PSOBKEY,
END OF T_PCONT.
DATA: BEGIN OF T_FIELDS OCCURS 0.
INCLUDE STRUCTURE help_value.
DATA END OF T_FIELDS.
DATA: BEGIN OF T_VALUES OCCURS 0,
VALUE(60) TYPE c.
DATA: END OF T_VALUES.
DATA: N TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK b20 WITH FRAME TITLE text-b02.
SELECT-OPTIONS:
P_CONT FOR ZPSPERMISOSH-PSOBKEY OBLIGATORY NO-EXTENSION NO INTERVALS,
P_INT FOR ZPSPERMISOSH-PARTNER OBLIGATORY NO-EXTENSION NO INTERVALS,
P_FEC FOR ZPSPERMISOSH-ZFINICN NO-EXTENSION NO INTERVALS,
P_RAZ FOR ZPSPERMISOSH-ZRAZONFINIC NO-EXTENSION NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b20.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_CONT-LOW.
PERFORM P_HELP_P_CONT USING P_CONT-LOW.
*& Form P_HELP_P_CONT
FORM P_HELP_P_CONT USING P_P_CONT.
DESCRIBE TABLE T_PCONT LINES N.
IF N EQ 0.
T_FIELDS-FIELDNAME = 'PSOBKEY'.
T_FIELDS-TABNAME = 'ZPSPERMISOS'.
T_FIELDS-SELECTFLAG = 'X'.
APPEND T_FIELDS.
CLEAR T_FIELDS.
SELECT PSOBKEY FROM ZPSPERMISOS
INTO TABLE T_PCONT.
SORT T_PCONT BY PCONT.
CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
EXPORTING
CUCOL = 10
CUROW = 1
TABNAME = 'T_PCONT'
FIELDNAME = 'PCONT'
IMPORTING
SELECT_VALUE = P_P_CONT
TABLES
FIELDS = T_FIELDS
VALUETAB = T_VALUES.
ENDFORM. " P_HELP_P_CONT
Edited by: J. Garibaldi on Nov 25, 2009 11:14 AM
Edited by: J. Garibaldi on Nov 25, 2009 11:16 AM -
Bluetooth is not working like before Ios 4.0 on 3GS
Since i have the update from soft 3.x to 4.0 i have problems in my car to connect to the Car Bluetooth Car-Kit.
I have a original BMW bluetooth Car-Kit wich was working perfect.
Since the update to version 4.0 most of the times it would not connect automaticly with the Car. so the connection is not always there.
After a little bit of pressing settings (bluetooth) on the phone the connection is made.
I am affraid to update again to the newer one 4.01 because maybeit will not working anymore.
Before the update to 4.0 there was no problem at all , everytime when in the car the connection was made automaticly without any problems. Now it is 2/10 auto connected.
Already removed the connection and paired it . but the result is the same. No stable automatic connection. Once connected there is no problem until next Car-Ride.
Anyone with a solution ?
Thx
DcaubThanks for your response ... yeah that's exactly what I wound up doing and it worked. Man what a nasty upgrade this has been.
Didn't expect to have to do a full restore of the iPOD. Of course that takes all the personal settings you made and nuked them back to the factory settings plus the latest system upgrade ... but hey ... it solved the problem. Wonder what's next? -
Get the value from dropdown list (selectedIndex) and text field -- not working
Hi All,
I am trying to find and change by the values selected by user using dropdown and text field. Here is the code.
ChangeRevDetails();
function ChangeRevDetails(){
var myDialog = app.dialogs.add({name:"Enter copyright information"});
// var monthlist = col1.dropdowns.add('myList', undefined, myList);
var col1 = myDialog.dialogColumns.add();
var col2 = myDialog.dialogColumns.add();
col1.staticTexts.add({staticLabel:"Month:"});
col1.staticTexts.add({staticLabel:"Year:"});
col1.staticTexts.add({staticLabel:"Rev. no.:"});
var myList = [ "January", "February", "March", "April", "March", "April", "May", "June", "July", "August", "Sepetember", "October", "November", "December" ];
var myMonth = col2.dropdowns.add({stringList:myList, selectedIndex:0, minWidth:100});//{minWidth:100});
var myYear = col2.textEditboxes.add({editContents:"2013", minWidth:100});
var MyRev = col2.textEditboxes.add({minWidth:100});
var RevMonth = (myList [myMonth.selectedIndex]);
var RevYear = myYear.editContents;
var RevNumber = MyRev.editContents;
var RevToReplace1 = RevMonth +", "+ RevYear;
var RevToReplace2 = RevMonth +", "+ RevYear + " Rev. " + RevNumber;
var myResult = myDialog.show();
if(myYear.editContents == "") //entry is ""
alert("Please enter some text into the contents field.");
ChangeRevDetails();
else if(myResult == true) //user entered datas
alert (RevMonth);
alert (RevYear);
alert (RevNumber);
alert (RevToReplace1);
alert (RevToReplace2);
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
// grep find/change
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "[\\l\\u]+?\\s?\\d{4},?\\s+[\\l\\u]+\\.*\\s+\\d+";
app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Back page"). paragraphStyles.item("Legal_7/9");
app.changeGrepPreferences.changeTo = RevToReplace1;
app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Back page"). paragraphStyles.item("Legal_7/9");
app.activeDocument.changeGrep();
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
else //implies user clicked cancel
myDialog.destroy();
The problem is, it is not taking the value which the user selects from the dropdown and the text field. It takes the default value as "January" and the year is "2013" as both of these values are given as selectedIndex:0 and editContents:"2013". I have compared the coding with some other working scripts as well, but it is not working. I have added several alert boxes to check the value we get.
Also, the find and change is also not working. Please help me on this. Thanks.
Regards,
Muthuraj. DChange the order for dialogresults:
var myYear = col2.textEditboxes.add({editContents:"2013", minWidth:100});
var MyRev = col2.textEditboxes.add({minWidth:100});
var myResult = myDialog.show();
if(myYear.editContents == "") //entry is ""
alert("Please enter some text into the contents field.");
ChangeRevDetails();
else if(myResult == true) //user entered datas
var RevMonth = (myList [myMonth.selectedIndex]);
var RevYear = myYear.editContents;
var RevNumber = MyRev.editContents;
var RevToReplace1 = RevMonth +", "+ RevYear;
var RevToReplace2 = RevMonth +", "+ RevYear + " Rev. " + RevNumber;
didn't have a look for the find change problem -
Photoshop color field not working in color picker
My color field is not working properly in my color picker. How do you fix this?
WRONG (what my color picking is doing) :
CORRECT (how it should work) :The catchall first step in correction is to reset the tool which, in this case, is the Eyedropper.
With the Eyedropper chosen, right click here:
If that doesn't solve the problem, a logical next step would be to reset your Preferences.
To reset Preferences:
If Photoshop is already open on your screen, close it (Quit). Then hold down Shift+Ctrl+Alt (Win) / Shift+Command+Option (Mac) on your keyboard and start Photoshop.
A dialog box will pop up asking if you want to delete the existing Preferences file (the "Settings"). Click Yes in the dialog box. The existing Preferences file will be scrapped and a new one will be created.
Maybe you are looking for
-
XML file in the form of .config file how to convert it to class and store it in single object
Hi, I have a config file in which i have to convert it to class and get an object. example: <?xml version="1.0" encoding="utf-8" ?> <xyz xmlns=""> <Container name ="Basic"> <Connectivity user="" server="" protocol="udp"/> <Connectivity user
-
Garageband 4.1.2 won't work in Snow Leopard. Why? Please help.
Garageband 4.1.2 won't work in Snow Leopard. Why? Please help.
-
How can i Get rid of verbal hel
How can i get rid of the microphone that wants to help me when i don't want help? It talks to me and shows up unexpectedly, esp. When i'm on the phone, and i loose the call trying to get rid of it.
-
Hi All, I am not getting Tax code field while maintaining RFQ in ME47. Can anybody tell me from where it should be activated ? Because i tried in screen layout for quotation in SPRO but it is not working ...
-
Different Web Server and JDK Version on the same machine
Dear All, There's a Orion App Servevr w/ JDK1.3 that running JSP. And I have installed the IBM websphere 5.0 SP2 w/ JDK 1.5 for another application in the same machine. When I tried to start the orion using cmd "java -jar orion.jar" for the original