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

Thank you David. I customise the button a little bit and it works like magic

Regards,
Tuan

TuanKhoa
Collaborator III

Jason, the code from David is very good

Regards,
Tuan

Glad you got it to work!

GhgcdMq8HwHRCWZuqMwEETnAH3l0sBKt8utOGHAgtsY= does great work!

TuanKhoa
Collaborator III

Thanks for your code too

Regards,
Tuan

Hi David Petty‌,

 

 

From the code, I can see that the nummer 20694 is the ID of the XREF field. So what is the nummer 4182 for?

 

The reason I'm asking is because I'm using different layouts in this application. The code just works for 1 layout, which means I have to change the nummer "4182" so that the code works for other layouts too.

 

Tuan

Regards,
Tuan

The 4182 has to do with the section id the field resides in.

 

You can use wildcard selector to just look for the later half of the id like so

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

 Advisory Consultant

Thanks.

 

I tried to do the same with the "Lookup" button but it doesn't work with the wildcard selector:

 

Old:    onclick="javascript:$find('master_DefaultContent_rts_s4182_f2694c').showLookup();"    <<   This works

New:   onclick="javascript:$find('[id*=f20694c]').showLookup();"   <<   This doesn't work

 

How do you think?

Regards,
Tuan

Referencing the lookup is a little bit more trickier being they've attached a function to the element.  You might not be able to do a wildcard selector on it.

 Advisory Consultant

That's what I guess. Thanks

Regards,
Tuan

You could try

 

onclick="$('[id*=f20694c]').find("Lookup")[0].click();"

 Advisory Consultant