Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Categories customisation with permission work (contd)

Status
Not open for further replies.

madhuusa

IS-IT--Management
Oct 5, 2006
93
US
Hello Nair,
I am posting my latest questions on this above topic in this new thread. My copy/paste of the response data has skewed the other thread.

#1:
Some of my requirements can be met by javascript. For instance in the attribute (called Status having values Active, Review, Attested) dropdown, only shift from Active to Review is allowed whereas all other shifts should not be allowed.
Question: Can I tap the attrrtset html file and put javascript for this. Although I understand when the attribute values changes (due to business req change) I have to re-code it. But since the business req is pretty frozen, can I do these validations in client side and is attrrtset the correct file.

#2: Once the shift happens from say Active to Review, I need to invoke API call to change the parent folder permissions. THis can be easily done. But how do I get the target value (in this case Review). It looks like I can find it in reponse but how do I parse this from the response which is an Assoc object.

Response object value is below.

A<1,?,'adminHelp'=false,'data'=A<1,?,'AttrAssoc'=<LL:Frame>{{fParent:#400346a}fAddedCategories:V
{<'Name','Key'>},fAttrChangePrefix:'',fData:A<1,?,{4376,3}
=A<1,?,'CustomID'=0,'ID'=1,'Values'=
{A<1,?,2=A<1,?,'ID'=2,'Values'={'Attested'}
>,3=A<1,?,'ID'=3,'Values'={false}>,4=A<1,?,'ID'=4,'Values'=
{false}>,5=A<1,?,'ID'=5,'Values'={false}>>}
>>,fDefID:?,fDefinitions:A<1,?,{4376,3}=A<1,?,'Children'=
{A<1,?,'DisplayName'='Status','FixedRows'=true,'ID'=2,'MaxR
ows'=1,'NumRows'=1,'Required'=false,'Search'=true,'Type'=10
,'ValidValues'={'Active','Review','Attested'}
>,A<1,?,'DisplayName'='Steward Sign
Off','FixedRows'=true,'ID'=3,'MaxRows'=1,'NumRows'=1,'Searc
h'=true,'Type'=5>,A<1,?,'DisplayName'='Attestor Sign
Off','FixedRows'=true,'ID'=4,'MaxRows'=1,'NumRows'=1,'Searc
h'=true,'Type'=5>,A<1,?,'DisplayName'='ESignature','FixedRo
ws'=true,'ID'=5,'MaxRows'=1,'NumRows'=1,'Search'=true,'Type
'=5>},'DisplayName'='EBinder','FixedRows'=true,'ID'=1,'MaxR
ows'=1,'Name'='EBinder','NextID'=6,'NumRows'=1,'Required'=f
alse,'Type'=-
18,'ValueTemplate'=A<1,?,'CustomID'=0,'ID'=1,'Values'={A<1,?,2=A<1,?,'ID'=2,'Values'={'Attested'}
>,3=A<1,?,'ID'=3,'Values'={false}>,4=A<1,?,'ID'=4,'Values'=
{false}>,5=A<1,?,'ID'=5,'Values'={false}>>}
>>>,fDeletedCategories:V
{<'Name','Key'>},fID:4587,fNoPermData:?,fPrgCtx:#41d61b1,fU
serData:?,fValueChanges:V{<'Key','Old','New'><'EBinder
[1].Status[1]','Attested','Attested'><'EBinder[1].Steward
Sign Off[1]',false,false><'EBinder[1].Attestor Sign


 
Bsically all you have to do is to make it into manageable assocs.For eg inspect the response assoc.Then look at the
response.data.attrData


The value is in this
Code:
response.data.AttrData.{2112,2}.Values[ 1 ].2.Values[ 1 ]='test'
In the above code 2112,2 means my category Id at version 2 ,passed from weblingo ,and in that assoc a text fields index .Rememeber that llattrdata is presented to you as a frame object.Between the AttrData and AttrDefinition assoc you can co-relate verything that you need(No hard coding is needed as far as if you wanted to know what is my attribute's display name and what its value is).I will further illustrate this concept with a 9.0 attribute aobject parsing.What it is doing is getting a attribute frame object,and looking at its internals.For eg I may have a document that has multiple categories attched to it,so I have to first loacte 'My Category' and in its definitions find the leaves.Please note that in this I am setting up a category value and I am only trying to show you the iteration,make suitable changes.

Code:
function  Assoc AddMyCategory(Object prgCtx,Integer myDataID,Integer VerNum,Record r,String seqnum)
//Example to set Attributes on new Folder
//vernum=0 does NOT mean latest version
Frame f = $LLIAPI.AttrData.New( prgCtx, myDataID, VerNum )
f.DBGet()
//Add the category to the folder
f.AttrGroupAdd( 2112 )

//Code to set attribute values
Integer categoryCounter = 0
Integer attrID
Dynamic category,attribute

for category in f.fDefinitions
    categoryCounter = categoryCounter + 1
    if category.DisplayName == 'First  Category'
                                
        for attribute in f.fDefinitions[categoryCounter].Children
            if attribute.DisplayName == 'First Text field'
                attrID = attribute.ID
                f.fData[categoryCounter].Values[1].(attrID).Values[1] = r.statusCode
            end
            if attribute.DisplayName == 'MyText'
                attrID = attribute.ID
                f.fData[categoryCounter].Values[1].(attrID).Values[1] = seqnum
            end
            //Ifs for other attributes go here.
        end
    end
    //Ifs for other cats go here.
end 

//Update database
f.DBPut()

end

I hope this helps

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Also your request object has the form fields,so if you wanted not too much an elegant solution you could use that as well.
for eg when I puts something in a form filed it is passed to livelink thru the request record
request._1_1_2_1

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Perfect. It worked great. I am able to get all the values of the attributes associated with the category linked to the node.

I am still wondering how do I go about the client side validation. I dont want to take everything to backend side and throw the livelink error screen. Will tapping Attrrtset.html be useful. Please advice.
 
if you wanted to do client side validation rememebr attrrtset.html is a generic webscript that is used to show
up any categpry in any livelink.So either you may to have to use a mapping utility such as htmlmap,otoverride or customizationrt so that your cahnges don't break it all together.Also I am not sure about this but attrrtset.html calls a baunch of other weblingo files for putting up that screen,so where do you get to do your javascript stuff ?Maybe this will work,you may need a flag somehwre to do this

If myFlag is true
I will execute a copy of attrtset.html in my module with the other associated weblingo's that paint the whole thing
else
Route to standard OT templates


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
You are right. What i was hoping to do was get the category in the oscript and if the category = my category then invoke the javascript for the elements of the form. So assume, if the category is the category I am looking, the the javascript wont even fire. I will try to do this to see how it goes.

Or the other way is throw the server error after making the checks on the server side.

I do not have htmlmap or other modules and I think I have to purchase those. Am I right?

I have an extra question too. I am looking at DAPI.AddNodeRight. This calls add user/group to a node with specific permission. How do I cascade the permission to all the subfolder/documents etc of a folder node. Do I have to listcontents and do it one by one. if that is the case, then what about new documents/folders since the permissions are not inherited since we have set it up one by one.
 
I got it. Below call does the trick.
Assoc result = $LLIAPI.NodeUtil.ApplyPermsToSubNodes( ParentNode )

Now the challenge is on the client side validation. If not possible easiliy, I will revert to server side validation.
 
I beleive customizationsrt is a free download from OTIt requires this module to be installed as well as your module..HTML map and otoverride may require licensing.I do not know how I got my hands on these but having seen modules developed by several OT/Non OT vendors I know that these exist.In fact on a recent project a real oscript guru(Donna Nalls) helped us put our module with the logic behind htmlmap module in our module itself.So in fact we were actually installing only one module ,but we were actually changing weblingo also,if you know what I mean.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
here's one more idea.I put a javascript in webattribute\attrsaction.html.The submit button calls a javascript routine and does an alert
Code:
;;webscript AttrsAction( Object prgCtx, Record request, Assoc data )
	<!-- File: webattribute/attrsaction.html -->

	//	To display the attribute action row with commands.
	//
	//	The caller of this web script should be a form with the following
	//	hidden names (unless it is in read only mode):
	//
	//	NAME="func" VALUE="ll"
	//	NAME="objId" VALUE="`request.ObjId`"
	//	NAME="Version" VALUE="`request.Version`"
	//	NAME="objAction" VALUE="AttrValuesEdit2"
	//	NAME="CacheID" VALUE="`request.CacheID`"
	//	NAME="nextURL" VALUE="`request.nextURL`"
	//	NAME="AttrSet" VALUE="`Str.ValueToString( data.AttrSet )`"

	;Dynamic	key = data.AttrSet
	;String		img = .Img()

  <SCRIPT LANGUAGE="JavaScript">
 					 function doSubmit( theForm )
  					 {
  					 var okSoFar=true;

                    alert(okSoFar);

  					//Read all the client variables and then submit only if our business rules
  					//are OK


  					if (okSoFar)
  								{
  								theForm.submit();
  								}


								}

  </SCRIPT>

	<INPUT TYPE="HIDDEN" NAME="ApplyCmd" VALUE="0">

	// The default attribute actions interface.

	<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0" BACKGROUND="`img`fon-table-header-gray.gif" STYLE="background-repeat: repeat-x;">
		<TR>
			<TD><IMG SRC="`img`spacer.gif" ALT="" HEIGHT="28" WIDTH="1"></TD>

			<TD ALIGN="CENTER">
				<INPUT CLASS="saveButton" TYPE="SUBMIT" NAME="subbutton" VALUE="`[WebAttribute_ButtonLabel.Submit]`" ONCLICK="doSubmit( this.form )">
				<INPUT CLASS="applyButton" TYPE="BUTTON" NAME="applyBtn" VALUE="`[WebAttribute_ButtonLabel.Apply]`" ONCLICK="applyData()">
				<INPUT CLASS="resetButton" TYPE="RESET" NAME="reset" VALUE="`[WebAttribute_ButtonLabel.Reset]`">
				;if data.DefCurrVer.( key[ 1 ] ) != key[ 2 ]
					<INPUT CLASS="button" TYPE="BUTTON" NAME="upgradeBtn" VALUE="`[WebAttribute_ButtonLabel.Upgrade]`" ONCLICK="upgradeSubmit()">
				;END
				<INPUT CLASS="deleteButton" TYPE="BUTTON" NAME="deleteBtn" VALUE="`[WebAttribute_ButtonLabel.Remove]`" ONCLICK="deleteSubmit( '`[WebAttribute_JavaErrMsg.ConfirmRemoveCategoryAndDeleteData]`' )">
				<INPUT CLASS="cancelButton" TYPE="BUTTON" NAME="cancel" VALUE="`[WebAttribute_ButtonLabel.Cancel]`" ONCLICK="location.href='`request.NextURL`'">
			</TD>
		</TR>
	</TABLE>

	<!-- End File: webattribute/attrsaction.html -->
;;end

It may probably work for you for JS validation

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thanks for the info Nair.

We have a mixture of attribute type and validation(for instance some validations are for drop down, for check box, for text box, text box auto populate based on checkbox checked value, etc)

Some of the validations can be done by the form level in the attrsaction javascript. But others like need that field level validation.

We went ahead and put those validations in attrboolean, attrString, etc. While doing so, we have put the functions in the attrsaction and just invoking the functions from the individual htmls (attrPopup, attrboolean, attrString).

We also invoke the javascript (which are in the attrsaction globally) in the individual html's one and only if the category = myCategory. Since all these files are global, this eliminates other risks.

1. Is this approach okay.
2. In order to do this we have to rely on hardcoded field names (like _1_1_2_1, _1_1_3_1). We are probing whether we can use form.element[0], form.element[1] because as we move across environments (dev, test, production) we can be safe. Is this possible.

I will also immediately look at CustomisationsRT and also try to get hold of htmlmap module (via my sales team).

I have not used htmlMap module before. My question is below:

The UI screen for us is the cats/atts screen. I have AttrAPI module in backend which is orphaned on the WebAttribute:RunTimeAction: AttrsValueEdit2. Now how will customisationRT and htmlMap work. Meaning, can I tell the cats/atts screen to listen to my html's (which will be a full copy of webattribute\html files + custom code) so that cats/atts UI will basically be AttrAPI UI.
 
I am not exactly sure but there is a file called
attrsjavascript.html or editattrsjavascript.html .Perhaps OT intended you to put all your own javascripts in there and call them generically.
Using HTMLmap and customizationsRT you are going to basically say something like if this flag is true let livelink load my templates.For eg I have used htmlmap to show up a "Export to Excel" button for livelink search results page.I read the condition off a ini file and then
use this button for doing some stuff those kind.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
We are working to get the htmlmap module eval copy/notes etc and hopefully it should help.

I have a question on the cascading permission function call to set permissions on subitems. Even if I do use the function ApplyPermsToSubNodes(Node) - this function applies to all subnodes the permission of the Node parameter - can the user of the group which has read/write permission on the Node, upload new content in the subfolder (say creating a subfolder).

It looks like ApplyPermsToSubNodes(Node) actually turns on permissions for exsisting node. IS this different from the cascade we manually do on this item/sub items from the permission screen.

If not this call, can you please tell me of the call which will make this happen.
 
From Documentation
Update all subnodes down the tree so that they have the
// same node level permissions and acl (except LLNode with fPermsRWD
// set to TRUE and workflow map attachments).
//

Also on the create thing.The business rule that LL employs is this(albeit simpler)
a)Is the user logged in
b)Does the user's group member ships allow individual subtypes to be created.Read this as the Object Factory creation privileges that you set up in admin.index.
c)Does the user have necessary permissions on container objects.Usually this is Add Items,Delete version & Reserve

I hope this helps





Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Hello Nair,
Thanks for all your help.

I was able to put the javascript in the common file and was easily able to invoke it. Also with the request param coming in, I am easily able to put the custom code only if the incoming param is of myCategory.

The permission functino also works fine. I made a coding mistake which reflected in wrong permission on backend side.

HtmlMap module should come very soon and with that I think I will have much cleaner work rather than touching all over webattribute files.

Once we go into full fledged development I will post more questions if needed on this topic.

Madhu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top