Basic Code Structure of an Edit Page

1 minute read time.
We should now consider the creation of an edit screen for a Record using an ASP page.

The structure is simpler.


var myBlock = eWare.GetBlock('OpportunityDetailBox'); 
var myRecordId = eWare.GetContextInfo('Opportunity','oppo_opportunityid'); 
//var myRecordId = Request.QueryString('oppo_opportunityid'); 
var myRecord = eWare.FindRecord('Opportunity','oppo_opportunityid='+myRecordId); 
eWare.AddContent(myBlock.Execute(myRecord)); 
Response.Write(eWare.GetPage());


The idea to always bear in mind is context. If you are dealing with a standard system entity (e.g. Company, Person, Opportunity etc) then you will be able to use the eWare.GetContextInfo() method to look for the primary key value for the record in context. From this you can then retrieve the record to be edited.

If you are working with a custom entity, perhaps one created using the Advanced Customization Wizard then you will need to get hold of the context information in another way as custom entities can't be accessed using the eWare.GetContextInfo() method.

The context information is held in the Key values of the hyperlink's query string.

The below code shows how to get hold of the correct key value that is contained in the querystring.


var strKeyID= "oppo_opportunityid"; 
var Id = new String(Request.Querystring(strKeyID)); 
var intRecordId = 0; 
if (Id.indexOf(",") > 0) 
{ 
var Idarr = Id.split(","); 
intRecordId = Idarr[0]; 
} 
else if (Id != "") 
{ 
intRecordId = Id; 
}


N.B. In ASP pages that are built using the Advanced Customization Wizard the querystring value that holds the context id value of the custom entity in context is "key58".
Parents
  • Thank you Jeff!!!

    I think I got it! :-) After reviewing your reply, it looked like the theory of what I was doing was on track so that is reassuring.

    I was reviewing the logs yesterday and I thought the correct select statement was coming through. (There is a lot of data to look through even if you rename the log file and let it regenerate a new one!!)

    I decided to look at the select statement from the list block that is returning data and compare it to the select statement from the screen block that I am not getting data on. They were not matching up even though I thought I had used the correct syntax in the definition of my LocContactRecord.

    I had this in the non functioning code...

    var LocContactRecord = CRM.FindRecord("LOCATIONSITE","ALIAS="+"'AddressAlias'");

    I changed it to this...

    var LocContactRecord = CRM.FindRecord("LOCATIONSITE","ALIAS='"+AddressAlias+"'");

    Those two lines sorta look the same...but the query string is different. For the query string, I pasted in exactly what we had on the list block for the Arg. And volia! Data!!! :-)

    I feel better that it was syntax, at least I did understand what I was doing, the syntax tripped me up! Thank you for helping me see that!!!

    P.S. This part of your reply made me laugh... MAKE SURE THAT YOU HAVE REMEMBERED TO INCLUDE FIELDS IN THE SCREEN. (I know it had to be asked.)

    Now I have to do some other stuff with this screen ... fingers crossed that I don't have to call out ... Jeff .. Help!!!

    As always...Thank you, Thank you, Thank you!!! For your assistance!

Comment
  • Thank you Jeff!!!

    I think I got it! :-) After reviewing your reply, it looked like the theory of what I was doing was on track so that is reassuring.

    I was reviewing the logs yesterday and I thought the correct select statement was coming through. (There is a lot of data to look through even if you rename the log file and let it regenerate a new one!!)

    I decided to look at the select statement from the list block that is returning data and compare it to the select statement from the screen block that I am not getting data on. They were not matching up even though I thought I had used the correct syntax in the definition of my LocContactRecord.

    I had this in the non functioning code...

    var LocContactRecord = CRM.FindRecord("LOCATIONSITE","ALIAS="+"'AddressAlias'");

    I changed it to this...

    var LocContactRecord = CRM.FindRecord("LOCATIONSITE","ALIAS='"+AddressAlias+"'");

    Those two lines sorta look the same...but the query string is different. For the query string, I pasted in exactly what we had on the list block for the Arg. And volia! Data!!! :-)

    I feel better that it was syntax, at least I did understand what I was doing, the syntax tripped me up! Thank you for helping me see that!!!

    P.S. This part of your reply made me laugh... MAKE SURE THAT YOU HAVE REMEMBERED TO INCLUDE FIELDS IN THE SCREEN. (I know it had to be asked.)

    Now I have to do some other stuff with this screen ... fingers crossed that I don't have to call out ... Jeff .. Help!!!

    As always...Thank you, Thank you, Thank you!!! For your assistance!

Children
No Data