Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object button that works as Add New button for XREF

TuanKhoa
Collaborator III

Hi,

 

I want to create a button by using Custom Object that does the same work as the "Add New" button for a XREF Field.

 

Capture.PNG

I tried to do something like this, but I just got the button, and nothing happened when I clicked on it.

 

<div style="text-align:center;"> 
 <a class="ContentURL" href="javascript:$('#master_DefaultContent_rts_s4182_f20694c_Add_New').click();"> 
  <img src="../BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:+++++AddNew+++++;iconSetStyle:VistaRound;baseColor:%23BFDDF5;disabled:False"/> 
 </a> 
</div>

 

I don't know how to put the "fieldid" - "refmodid" - "moduleid" in the code.

 

Could anyone help me With this? Thank you!

 

/Tuan

 

GhgcdMq8HwHRCWZuqMwEETnAH3l0sBKt8utOGHAgtsY=

Regards,
Tuan
76 REPLIES 76

Oh I see now. I change from "f20694c" to "ss20694" then it works

Regards,
Tuan

Yep, key is using the correct element ID

 Advisory Consultant

You said you hadn't found a way to supply field name...

If you figure that out, I need to know ASAP!!!

That would save a bunch of code... Until the end users want to change their field name... Which never happens. LOL

image002.png

 

It worked for "Add New", but I'm still struggling with "Look Up"

 

I tried to use "ss20694_f20694c" as ID but the LookUp button doesn't react

Regards,
Tuan

jsol5
Advocate II

Tuan,

Just sharing something I discovered the other day...

If you have these 'add new' xref buttons available on a brand new record, it may not work the way you expect.

A brand new record doesn't necessarily have it's record ID.  So, until the user clicks save to generate and display their Archer record ID, I had my add new buttons.

 

So, I did something like this:

 

//double-checking that the elemtn wtih this class exists
if(document.getElementsByClassName("frame-title-key")){
//checking if add new record is the text contained in the element. If it is, then this is new record and we won't be able to add communication logs
if(document.getElementsByClassName("frame-title-key")[0].innerHTML.indexOf("Add New Record")>=0){
showbuttons= false;
}
}

then, if showbuttons = true, then I perform the rest of my code to display the add new buttons.

Have you tried what we used before; adjusting for the id?

https://community.rsa.com/message/909434?commentID=909434&et=watches.email.thread#comment-907463

 

Might have to edit it to look for the title instead

<a href="#" onclick="$('[id*=f15537c]').find('[title=Lookup]').click();">Lookup</a>

 Advisory Consultant

TuanKhoa
Collaborator III

Thanks for sharing!

 

My button is placed in the midle stage of the AWF, which means the record is already saved

Regards,
Tuan

To check to see if the record is new or existing use getRecordId();  It will return 0 for a new record or the actual tracking id.

 Advisory Consultant

DavidBaldwin1
Contributor III

km8xRogUTizVFQ8S1sMIAXnMpfPvhtBs ... I never intended for you to use that information per se. It was more for David Petty. Since he asked... you may be able to find something in here worth using here...but here you go GhgcdMq8HwHRCWZuqMwEETnAH3l0sBKt8utOGHAgtsY=

get all fields on layout

1. Get list of fields: $CM.get_fields()

This will get you all the fields on the page even if that field is hidden. The only fields it won't get you are the fields that are on other tabs. The output will be in the form of a dictionary of dictionaries.

 

Now there are 10 ways to do step #2-#3 nevertheless... the goal is to map field_id->field_name

Also note: #2-#3 is optional if you do not mind dealing with code that requires you to update the id for each Archer environment you code lives in. In your case, it sounds it would be more efficient to just live with the need to configure it.

 

Now you want map field_id -> field_loitem

2. Once you have all the fields you use jQuery to cycle through all the fields. each field will contain a  collection of attributes: active, clientid, display control, layout, setionid, type, etc. The clientid of a field is the "master_Default..." that you are use to seeing. use jquery's .parent() to get the node that is the immediate parent of this node. when you look at this parent's name ... you will see a "loitem#". Get this loitem# because you will need it later

I believe you can use the $LM for this ... but I cannot promise that...more specially I cannot remember

 

Now you want the field_loitem->field_name

3. Now with the loitem# you can get all the html tags that have the id="loitem[#]". This will get you the field name.

in particular <span id=[loitem[#]]> Hello World </span>.

Now since:

field_id->field_loitem-> field_name ... then we can search our personal object for field_name and get the corresponding field_id without ever needing to update our configuration object.

 

 

 

Get Control of the field so that you can manipulate it

4. $CM.getFieldById(80123) will get you want you need to manipulate the field in question

 

 

This is as far as I can take you without my employer probably wanting to take ownership

Disclaimer: This represents my opinion and not the opinion of my employer or colleagues.

Yes David that works, but since I use different layout so I'm trying not to include section ID in here

 

And I tried "Title" instead of "ID", still doesn't work

Regards,
Tuan