Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Element Ids in Custom Object javascript

JeffLamb
Contributor II


I have a very fundamental question regarding javascript in custom objects. How do I determine the element id of a field I want to reference in the javascript?

 

I have a simple requirement where we need to clear the contents of a text field when the record is opened for editing. Seems like it should be easy to implement this with a custom object, but I don't know how to get the element id of the field so I can reference it within the custom object.

 

If it matters, I'm using Archer 5.2 but we will be moving to 5.3 SP1 soon.

31 REPLIES 31

Are you looking to get the value in edit or view mode?  Is the field on the layout?  Is the field calculated?  Is the field viewable; meaning it's not on a tab that isn't currently visible to the user?

 Advisory Consultant

Anonymous
Not applicable

I have been trying in View mode.  I just tried Edit mode and it did pop-up with the value from at text field.

So, will this not work in View mode?

 

Also, I wanted to be able to pull from any field type and am unsure if I would need a different code snippet, for lack of a better word, for the element.  (I'm unsure why we are wrapping the element id with f and c and if div will work on any field type).

 

So, lets say I wanted to pull the tracking ID or the service identifier form the Products and Services core application in view mode.

 

You may ask why would I want to do that, and this is step one in my POC.  i want to eventually see if I can create a link on the P&S that will pull a dynamic report by passing in it's service code or service identifier.

The fields act differently when you are in View mode vs. Edit mode.

 

For view mode or calculated fields you would use

$(span[id*="f20223c"]').text();

 

For edit it would be mostly

$('input[id*="f20223c"]').val()

 

For the various field types you can use IE Developer Tools.  To invoke the tools hit F12.  Then you need to locate the field you want to get data from and in the developer tools window click the HTML tab if not already selected and click on the "Select element by click" button in the toolbar, icon looks like a mouse pointer.

 

Once clicked move your mouse over the field till you get a blue outline around the field.

blueoutline.png

Once highlight, click.

 

Then you see in the HTML tab with the highlighted code where you can get what type of element it is; div, span, input and it's id.

ElementSelection.png

 Advisory Consultant

Anonymous
Not applicable

Thanks for the info.  I must've done something odd, yesterday, because I wasn't able to click on the individual elements, but it's working now.

I might have been debuggin the page on the Script tab.

 

But, anyway, my next question is, without checking if the master buttons are disabled how can I check if I'm in edit mode or view mode?

 


Add this to your code

 

var recordState = ArcherTech.UI.GenericContent.GetInstance().get_mode();   // 1 = Edit, 2= View

 Advisory Consultant

Hi David,

 

Using the above, I was trying to build the following formula but did not work, could you help

 

concatenate("<a_href=""javascript:parent.showOptions("%2FGenericContent%2FExportReportCreation.aspx%3FcontentId%3D",[Policy Tracking ID],"%26levelId%3D3%26exportSourceType%3DRecordView%26exportType%3DRtf%26moduleName%3DPolicies%26templateId%3D3", "Selection Dialog");">ABC</A>")

Darshan all javascript is stripped from calculated fields.

 

Try this in a custom object

<a href="javascript:parent.showOptions('%2FGenericContent%2FExportReportCreation.aspx%3FcontentId%3D' + getRecordId() + '%26levelId%3D3%26exportSourceType%3DRecordView%26exportType%3DRtf%26moduleName%3DPolicies%26templateId%3D3', 'Selection Dialog');">ABC</A>

 Advisory Consultant

Thankd David. it worked.

 

I actually wanted to provide a user a link to the whole policy in a window(including its areas and sections) (probably that would be a dynamic report with the filter criteria being the record id) Can I do that using a custom object? or any other suggestions.

 

For now i have used this custom object you sent to provide the user with a link to extract the mail merge template of that record/policy.

Also, is there a function to get the record Id of the record which is cross referenced from an application.

 

i.e if I have a questionnaire and want to know the record ID of the target.

Hi David,

 

I know this chat is long before.  Can you help me with the solution, how to get the cross reference values? Below is the code, i can get the other field values but not the cross reference fields

<script type="text/javascript">

$(document).ready(function(){

var RefField= $('#master_DefaultContent_rts_s5835_f29602srvgrid_ctl00_ctl04_f29602:29621c').text();

var NormalField = $('#master_DefaultContent_rts_s5815_f29622c').text();

alert(RefField); // Not working, Returns a empty text in alert box

alert(NormalField); //Working, Returns the field value in alert box

});

</script>