Adding/Updating comments using design studio

 17 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
Mike LaCosse
Basic Member Send Private Message
Posts: 6
Basic Member
I am creating a custom form for AR17 and have added a text box in the detail section for comments (so it doesn't take several clicks for users to add a comment). I am having limited success getting the writeattach.exe cgi to add/change the comments. Has anyone been able to use this to add a comment field to a form, and if so would you mind sharing some code?

Thanks,
Mike
mlacosse@midway.com
Mike LaCosse
Basic Member Send Private Message
Posts: 6
Basic Member
I did get this working eventually. I added a text box to the detail line, and then added a function to call the writeattach.exe or getattachrec.exe program.

Here is the function I created that is called when someone inquires on the form. This grabs the comment (if it exists) and puts it in the text box (text9):

function getComment(vRowNum)
{
//
// var vFC = lawForm.getDataValue("LINE-FC",vRowNum);
var vCompany = lawForm.getDataValue("CMT-COMPANY");
var vCustomer= lawForm.getDataValue("CMT-CUSTOMER");
var vSeqNumber = lawForm.getDataValue("CMT-SEQ-NUMBER",vRowNum);
if (vSeqNumber == 0) return true;
// alert (vSeqNumber);
//code for getattachrec.exe
var s = "http://ourURL.com/cgi-lawson/getattachrec.exe";
s += "?_OUT=XML";
s += "&_PDL=LAWAPP8";
s += "&_FN=ARCOMMENT";
s += "&_IN=CMTSET1";
s += "&K1=" + vCompany;
s += "&K2=" + vCustomer;
s += "&K3=" + vSeqNumber;
s += "&_ATYP=C";
s += "&_AUDT=A";
s += "&_KS=99";
s += "&_OPM=A";
s += "&_DATA=TRUE";
s += "&_ECODE=FALSE";
s += "&_ATTR=TRUE";
s += "&_AOBJ=TRUE";
s += "&_AESC=IE";
s += "&_AESC=IE";
// alert(s);
var sReturn=portalWnd.httpRequest(s);
//create an XML object to contain the DME data
var vObjXML = new portalWnd.DataStorage(sReturn);
//load a variable with the records returned by getattachrec call
var vRecords = vObjXML.document.getElementsByTagName("AttData");
// alert(vRecords.length);
//in case there is no comment associated with the record...
if (vRecords.length == 0) return true;
var vComment = vRecords[0].firstChild.data;
lawForm.setFormValue("text8",vComment,vRowNum);
//get name of specialist too
var vRecords = vObjXML.document.getElementsByTagName("AttName");
if (vRecords.length == 0) return true;
var vSpecialist = vRecords[0].firstChild.data;
lawForm.setFormValue("text9",vSpecialist,vRowNum);
return true;

}

Here is the code to add/change a comment. This solution will only allow 1 comment to be added per detail line, which was not a problem for us. We also made the employee ID (specialist) the title of the comment so we could track who was entering the comment.

The addComment function actually adds the comment. It uses the commentExists function (below) to determine if a comment already exists, and simply changes the existing comment instead of adding a new one.

function addComment(vRowNum)
{
//
var vProductline = top.lawsonPortal.getUserVariable("PRODUCTLINE");
var vUserName = top.lawsonPortal.getUserVariable("USERNAME");
var vCompany = lawForm.getDataValue("CMT-COMPANY");
var vCustomer= lawForm.getDataValue("CMT-CUSTOMER");
var vFC = lawForm.getDataValue("LINE-FC",vRowNum);
var vSeqNumber = lawForm.getDataValue("CMT-SEQ-NUMBER",vRowNum);
var vComment=lawForm.getFormValue("text8",vRowNum);

//build the API call for the writeattach cgi
var s = portalWnd.WRITEATTACHPath;
s += "?_OUT=XML";
s += "&_PDL=" + vProductline;
s += "&_FN=ARCOMMENT";
s += "&_IN=CMTSET1";
s += "&_ATYP=C";
s += "&_AUDT=A";
s += "&K1=" + vCompany;
s += "&K2=" + vCustomer;
s += "&K3=" + vSeqNumber;
s += "&_OPM=M";
s += "&_DATA=TRUE";
s += "&_ANAM=" + vUserName;
s += "&_ATXT=" + vComment;
s += "%20&_AESC=IE";
if (commentExists(vSeqNumber))
{
//if change:
s += "&_KS=99"
}
else
{
//if add:
s += "&_USCH="
}
s += "&_ATTR=TRUE";
s += "&_AOBJ=TRUE";
s += "&_ECODE=FALSE";
// send API to the server
var sReturn = top.httpRequest(s);
return true;
}


function commentExists(vSeqNbr)
{
// alert(vSeqNbr);
var vCompany = lawForm.getDataValue("CMT-COMPANY");
var vCustomer= lawForm.getDataValue("CMT-CUSTOMER");
//code for getattachrec.exe
var s = "http://ourURL.com/cgi-lawson/getattachrec.exe";
s += "?_OUT=XML";
s += "&_PDL=LAWAPP8";
s += "&_FN=ARCOMMENT";
s += "&_IN=CMTSET1";
s += "&K1=" + vCompany;
s += "&K2=" + vCustomer;
s += "&K3=" + vSeqNbr;
s += "&_ATYP=C";
s += "&_AUDT=A";
s += "&_KS=99";
s += "&_OPM=A";
s += "&_DATA=TRUE";
s += "&_ECODE=FALSE";
s += "&_ATTR=TRUE";
s += "&_AOBJ=TRUE";
s += "&_AESC=IE";

//the following 4 lines of code return false if a comment doesn't exist
var sReturn=portalWnd.httpRequest(s);
//create an XML object to contain the DME data
var vObjXML = new portalWnd.DataStorage(sReturn);
//load a variable with the records returned by getattachrec call
var vRecords = vObjXML.document.getElementsByTagName("AttData");
if (vRecords.length == 0) return false;
return true;

}
John Henley
Send Private Message
Posts: 3351
Excellent work!
Thanks for using the LawsonGuru.com forums!
John
Deleted User
New Member Send Private Message
Posts: 0
New Member
I am trying to do this, and I'm not sure if it is a design studio issue per se.

I have a custom COBOL program that I have a comment button for, in the same fashion as AP30.1 has, for example.

I've got it to work in LID with the proper RULEs, SCRDTLs and OBJWINs in the screen/object rule files.

However, in Portal, I get "Error Loading XML Document" for my custom COBOL program. Please note, that in Portal, other comment buttons (such as AP30.1) work without a hitch.

I tracked this down to a bad QUERY_STRING being used by getattachrec.exe, and I think the real culprit is servlet/ida, which generates the getattachrec.exe calls in CDATA XML, in Portal.

My question is, how do I properly configure my custom program to allow for attachments in Portal, and not just LID?

Thanks,
Phil
John Henley
Send Private Message
Posts: 3351
You don't have to do anything special to make it work in Portal. Do you have the $COMMENTKN mapped to the correct SKN in your .scr file (I'm assuming you do since you say it works correctly in LID). Are you modifying the form in Design Studio? You might want to check for IOS patches for your particular platform/version.
Thanks for using the LawsonGuru.com forums!
John
Deleted User
New Member Send Private Message
Posts: 0
New Member
John, thanks for the reply

I indeed have $COMMENTKN and $URLKN, and it does work in LID. I am indeed modifying the form in Design Studio. However, I have also taken Design Studio out of the equation, by creating a new custom program, and just using lawson screen paint and design studio quick paint to generate the forms.

I think I might be missing something in my .or or .sr files, but I don't know what, and my eyes have glazed over on multiple occasions trying to pick these files apart.

So far my witch's brew consists of:

=======================
AC.sr
=======================

DEFINE RULE
ID AC-DKV-R-0001
SCRFLD BNN-CLIENT-ID-Z03,BNN-JOB-NUMBER-Z04
FILENAME DKACTIVITY
INDEX DKVSET1
KEYRNG BNN-CLIENT-ID-Z03,BNN-JOB-NUMBER-Z04
RETURNS BNN-CLIENT-ID INTO BNN-CLIENT-ID-Z03

DEFINE SCRDTL "BNN ID"
ID AC-DKV-D-0001
SCRFLD BNN-CLIENT-ID-Z03,BNN-JOB-NUMBER-Z04
FILENAME DKACTIVITY
INDEX DKVSET1
KEYRNG BNN-CLIENT-ID-Z03,BNN-JOB-NUMBER-Z04

.
.
.
=======================
AC.or
=======================
DEFINE OBJWIN "BNN Comments"
ID AC-DKV-W-0001
FILENAME DKACTIVITY
COMMENT TYPE=C
WINFLDS BNN-CLIENT-ID: " BNN Client ID, Job:",BNN-JOB-NUMBER:" "
ACTIVITY: " Activity:",DESCRIPTION:" "

.
.
.
=======================


This seems to be enough for LID but not for Portal


our versions are:

univver -V
Version: 8.0.3.ESP6 (8.0.3.6.4) 2005-07-28 22:00:00
univver $CGIDIR/getattachrec.exe $CGIDIR/ida.exe
getattachrec.exe: 8.0.3.6.4 2005-07-28 22:00:00
ida.exe: 8.0.3.6.4 2005-07-28 22:00:00

We are patched to the limit, as far as I know.

Thanks,

Phil
John Henley
Send Private Message
Posts: 3351
I would take Design Studio out of the mix, and just pull up the custom form in Portal. In other words, don't do the quick paint in Design Studio.
One hopefully stupid question--in dbdef, did you enable attachments for your custom DKACTIVITY table?
P.S. As for "patched to the limit", you are not--otherwise you'd be on 8.0.3.7!! :)
Thanks for using the LawsonGuru.com forums!
John
Deleted User
New Member Send Private Message
Posts: 0
New Member
Yes I enabled attachments in dbdef, did blddbdict and dbreorg -- otherwise LID would not work either :)

This is driving me insane, and I've done my share of Lawson mods in the past.
John Henley
Send Private Message
Posts: 3351
Did you try it without Design Studio, and just run it in Portal via the token?
Thanks for using the LawsonGuru.com forums!
John
John Henley
Send Private Message
Posts: 3351
After you compile, are you getting an updated .xml file?
In other words, when you compile, is it running xscrgen?

In the xscrgen-generated .xml file, look for the keynbr= line that matches the $COMMENTKN you set up in the .scr file.
Make sure that line with the keynbr= also has this attribute: att_comment="1"
Thanks for using the LawsonGuru.com forums!
John
Deleted User
New Member Send Private Message
Posts: 0
New Member
[quote]Posted By John Henley on 9/27/2007 2:56 PM

Did you try it without Design Studio, and just run it in Portal via the token?[/quote]

Yes, I created a new program in pgmdef, screen painted (in pgmdef) it using the file that has attachments enabled in dbdef. Then using LED I edited the .scr file (Form Definition file), adding a button [CMT] at the end, and defining it something like this:

2 CMT W 3 LB Z03=CMT

Z03 is my skn

Then I scrgened and loaded the program in LID. "CMT" button works fine I can add/modify comments as I please.

At this point I haven't touched design studio for this new screen-painted program.

Now I open portal, enter the program token in the search, and there it is. I hit Next to pull up a record use the CMT button (which renders as a blue underlinked hyperlink in Portal but whatever) but get the same problem as before: The Attachments window pops up, with a COMMENT folder, I click '+' to expand that, and my particular comments folder pops up now called BNN COMMENTS, I click '+' to expand that, and I get 'Error loading XML Document' in the status bar.
Deleted User
New Member Send Private Message
Posts: 0
New Member
Indeed, the XML for my little test program (in /lawson/.../map/default), as well as my design studio XML (in /usr/apache/htdocs/lawson/portal/content/forms) for the main program, both have att_comment="1" for the button, and for the key fields (which I guess allows for the right-click,attachments action in portal)

edit: yes, the XML files are being updated because their timestamps are being renewed
John Henley
Send Private Message
Posts: 3351
Does right-clicking in the key fields bring up an attachments window and if so, does it work correctly?
Thanks for using the LawsonGuru.com forums!
John
John Henley
Send Private Message
Posts: 3351
Also, do you have Z03 defined on any other lines in the $TRANS section of the .scr ?
Thanks for using the LawsonGuru.com forums!
John
John Henley
Send Private Message
Posts: 3351
Hi Philip,
Were you able to test this without the comment [CMT] button in Portal (i.e. via right-click on the key field(s))?
Thanks for using the LawsonGuru.com forums!
John
Deleted User
New Member Send Private Message
Posts: 0
New Member
John,
Thanks for sticking with me. Yes I tried the right click action on the field, and I get the same problem. I'm all out of ideas. I'll post more when I am able to VPN into the clients machine, tomorrow maybe.
Randall
Veteran Member Send Private Message
Posts: 44
Veteran Member

This seems to be an older post, but I'm running into the same problem.  I've tried the posted soultion with &_KS=99 and it tells me that the Attachment Record cannot be found.

I am doing comments to PO.  I did find if I used getattachrec using &_KS=zz, then it did work, however when I try to update using writeattachrec and the same value, it returns a message that it has been updated, but it does nothing.

This is my getattachrec that returns true (where comment type is either "HISTORY" or "PHYS DESC"):

    var vCompany = lawForm.getDataValue("PCR-COMPANY");
    var vPONumber = lawForm.getDataValue("PCR-PO-NUMBER");
    var vPORelease = lawForm.getDataValue("PCR-PO-RELEASE");
    var vPOCode = lawForm.getDataValue("PCR-PO-CODE");

    //code for getattachrec.exe
    var s = "/cgi-lawson/getattachrec.exe";
    s += "?_OUT=XML";
    s += "&_PDL=" + strPDL;
    s += "&_FN=POLINE";
    s += "&_IN=PLISET1";
    s += "&K1=" + vCompany;
    s += "&K2=" + vPONumber;
    s += "&K3=" + vPORelease;
    s += "&K4=" + vPOCode;
    s += "&K5=" + vPOLine;
    s += "&_ATYP=C";
    s += "&_AUDT=O";
    s += "&_KS=zz";
    s += "&_OPM=A";
    s += "&_DATA=TRUE";
    s += "&_ECODE=FALSE";
    s += "&_ATTR=TRUE";
    s += "&_AOBJ=TRUE";
    s += "&_AESC=IE";
    s += "&_ANAM=" + commentType;

 

My writeattachrec is as follows:

            var vCommentAttach = "/cgi-lawson/writeattach.exe?_OUT=XML&_PDL=" + strPDL
            vCommentAttach += "&_FN=POLINE&_IN=PLISET1"
            vCommentAttach += "&K1=" + vCompany
            vCommentAttach += "&K2=" + vPONumber
            vCommentAttach += "&K3=" + vPORelease
            vCommentAttach += "&K4=" + vPOCode
            vCommentAttach += "&K5=" + vPOLine
            vCommentAttach += "&_ATYP=C&_AUDT=O"
            vCommentAttach += "&_ATTR=TRUE";
            vCommentAttach += "&_AOBJ=TRUE";
            vCommentAttach += "&_AESC=IE"

            if (commentExists(vPOLine,"HISTORY")) {
                // change if it exists
                vCommentAttach += "&_KS=zz"
            } else {
                // add if it does not exist
                vCommentAttach += "&_USCH=none"
            }

            vCommentAttach += "&_DATA=TRUE&_OPM=M&_ECODE=FALSE"
            vCommentAttach += "&_ANAM=" + "HISTORY"
            vCommentAttach += "&_ATXT=" + vHistoryComment

Is there documentation on what all these parameters mean?  I've searched the support site, this site, and the web without much luck.  Any help would be appreciated.

 

Thanks,

Randall

David Williams
Veteran Member Send Private Message
Posts: 1127
Veteran Member
See my blog entries to see if they will be of any help.

http://consultdavidw.blog...chrecexe-cgi-to.html

http://consultdavidw.blog...d-po20-form-for.html
David Williams