A previous article "Creating a Codeless Search Screen on an External Database using RunBlock" discussed the simple steps needed to create a search page that retrieved data from an external database table.
The screen allowed a user to filter and retrieve data and then page through the results. But how can we create a simple view/edit screen to allow the details of these search results to be seen?
In this screen we can see that in addition to simple notifications being displayed this screen also has
- A coaching caption
- A change button
- Top Content
To create a screen like this requires the following steps.
- Create a simple screen of screen type 'Entry Screen' to display the record.
- Add some client side code to build the TopContent display.
- Create a block of Type 'EntryGroup' based on the screen created in step 1. This will allow the correct formatting of the screen.
- Add a hyperlink to the list column of Type 'RunBlock' that will call the block created in step 3.
- Test the screen and add the coaching caption.
Add the entry screen based on the external table.
The screen can include any fields you need.
Because this is a screen based on an external entity, when RunBlock is called, by default, there will not be any data added to the top part of the screen. This is the TopContent area and in order to avoid this being blank and the screen looking odd we can add some clientside code that will populate the TopContent area.
This code is added to the custom content box of the screen block. It uses a function called WriteToFrame() which is actually the way in which all Sage CRM screens create the TopContent data. A previous article discussed this, "Controlling Top Content".
//firefox way of binding an event
window.addEventListener("load", RefreshTopContent, false)
//IE exclusive method for binding an event
//use in ASP pages, content blocks and custom content of Screen Blocks
var strTopContent = "<TABLE><TR><TD><IMG SRC='../Themes/img/color/Icons/company.png' HSPACE=0 BORDER=0 ALIGN=TOP ></TD><TD align=right class=topcaption>"+_Captcompanyname.innerHTML+"</TD><TD class=topheading>"+EntryForm._HIDDENcompanyname.value+"</TD></TR></TABLE>";
parent.frames.WriteToFrame(5,"TOPBODY VLINK=NAVY LINK=NAVY",strTopContent);
The caption of the field and the data have been read from the screen information.
The block has to be created. Make sure that this is based on the EntryGroup or screen you created in step 1.
Note: Using simple Sage CRM screens like those generated by RunBlock to update values held in another database can create problems. There may be business rules or integrity constraints which can not be handled correctly. It maybe better to use RunBlock to only create ReadOnly screens. If you want to ensure that the record can not be edited, then make certain that the field 'Show Default Button' is set to 'No'.
Note: The text entered in the title field of the block will return the translation for that caption code in the caption family 'Tabnames'. If you have entered 'Contact' as the title, when the user accesses the screen it will look at the custom_captions meta data table e.g.
select * from custom_captions where capt_family='tabnames' and capt_code = 'contact';
If the user's language is German it will return 'Kontakt' as the translation.
The hyperlink to the screen needs to be added to the list block. The hyperlink should call Runblock and the name of the block and the primary key of the external table needs to be referenced.
Coaching captions allow HTML formatted text to be delivered into a screen. This includes extensions built using RunBlock or the .NET API and classic ASP pages. You can read about how to use Coaching Caption in the article "In command with On-Demand - guiding user behaviour" https://community.sagecrm.com/user_community/b/ondemandteam/archive/2011/03/09/in-command-with-on-demand2.aspx