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
1 ACCEPTED SOLUTION

Accepted Solutions

For the URL construction take a look at this post from Scott, https://community.rsa.com/message/894163?commentID=894163#comment-893018

 

I've tested below and it works fine.  The [0] is need do to how jQuery works with links and click events.

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

 Advisory Consultant

View solution in original post

76 REPLIES 76

DavidPetty
Archer Employee
Archer Employee

Tuan the custom object you've listed should be fine.  Are you getting any javascript errors or is the cross-reference field located on a different tab that's not visible to the user?

 Advisory Consultant

Hi David,

 

I do not get any javascript error. When I click on the button, nothing happened. And the XREF field is on the same page of the custom object field.

 

/Tuan

Regards,
Tuan

Are you sure your button name of master_DefaultContent_rts_s4182_f20694c_Add_New is right?

I'm not sure that this is it, but I'm noticing that my add new buttons in one of my applications is not _f....c_Add_New.  

I'm also noticing that the add new button ID doesn't actually contain my x-ref field ID. 

...Maybe it's different for a different xref, but in both my scenarios, I have to find my field by ID in the DOM.  Then, using jquery, I navigate up the DOM to find the section container and then previous container that actually contains the add-new button as child element.

 

Also, you're doing it differently than me, but I didn't see anything in your code containing the data-check-dirty flag.

 

TuanKhoa
Collaborator III

Hi,

 

I'm quite sure the button name is correct. I use the Developer Tool > DOM Explorer to get the name (as in the pic from my question).

 

By the way, I just use the "template" of David Petty‌ (as stated in my question).

 

Tuan

Regards,
Tuan

Hi David Petty,

 

When I change the class from "ContentID" to "CrossReferenceAddNew", the button starts to react when I click, but then I'm redirect to another page. On the page, there's just a text string [object Object].

 

Can you show me how "CrossReferenceAddNew" works, and if it is correct to use this class in this case?

 

Tuan

Regards,
Tuan

Tuan what version of Archer are you on?  Also how is the cross-reference field configured; grid or single-column?

 Advisory Consultant

I'm running Archer v.6.3 P4, and the XREF Field is configured as single-column.

 

From the redirected page, I can see this from the URL bar:

 

https://abc.com/Archer/apps/ArcherApp/Home.aspx#record/[moduleId]/291/[contentid]

 

I think 291 could be the Dashboard ID of the application. Btw, what is the "refmodid"?

Regards,
Tuan

For the URL construction take a look at this post from Scott, https://community.rsa.com/message/894163?commentID=894163#comment-893018

 

I've tested below and it works fine.  The [0] is need do to how jQuery works with links and click events.

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

 Advisory Consultant

Just throwing this out as an alternative to the template you mention.  I haven't tried the template.  So, I couldn't tell you what's wrong with it.  But, I have found that just building the elements using jquery/javascript works pretty well. 

 

 

if(!document.getElementById("yourbuttonamehere"))
{

var newbtn = document.createElement("a");
newbtn.id="yourbuttonamehere";
newbtn.className="tb-btn-link-left";
newbtn.href="javascript:void(0);";
newbtn.title="Add Submitter Log" ;
newbtn.setAttribute("data-check-dirty","true");

var ndiv = document.createElement("div");
ndiv.id = "btnAddnewSubmitterLogDiv";
ndiv.className="tb-btn";
ndiv.setAttribute("data-icon-pos","left");
ndiv.innerHTML="Add Submitter Log";

newbtn.appendChild(ndiv);
document.body.appendChild(newbtn);

$("#yourbuttonamehere> div").attr("data-icon","&#xe134");
$("#yourbuttonamehere").detach().appendTo('.toolbar-app-buttons-left');
$("#btnAddnewSubmitterLogDiv").attr("style","color:#299410 !important");

$("#btnAddnewSubmitterLog").click(function(){
$('[id*="f' + yourbuttonamehere_Field_ID + 'c"]').parents().closest('tr[class^="section-content"]').eq(0).prev(".section-head").find(".add-new").click();