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
  • Thanks Jeff...

    The 'Arg' is a whereclause that only makes sense when restricting a list.

    I had a feeling it was going to be something around the Arg. However, I could not find enough information to help me get that straight.

    If I understand what you are saying...'Arg' can only be used with a ListBlock. If I am using a screen block, I need to pass my record.

    What is going to trip me up here is that the AddressRecord is not the record that I need to display, I need to display the Contacts associated with that AddressRecord from an external table (I didn't design how these connect..however, that is the connection I have to work with. :-)). The system is designed so that when you are working with the locations, the user is in the context of the Address entity. Therefore, the addr_addressID is what you can pull out of the URL. On the address record in CRM is a field for the location alias. The alias is the unique identifier in the external table for the record I want.

    Therefore, I am getting to the record this way ---> Address ID ---> addr_localias ---> addr_localias = alias ---> alias = myRecord in the External database.

    Since I believe I understand that I need to pass a record not an Arg to the screen block, I need to figure out how I filter that record to the actual record that I want. I am sure that I have seen how to do this before...just don't remember how. If I were writing SQL, I could do it.

    I am off to do more research on FindRecord and I am hoping that is the direction I need to go. If I am headed in the wrong direction, please let me know and shove me in a different one!

    Thank you for your assistance!!!

Comment
  • Thanks Jeff...

    The 'Arg' is a whereclause that only makes sense when restricting a list.

    I had a feeling it was going to be something around the Arg. However, I could not find enough information to help me get that straight.

    If I understand what you are saying...'Arg' can only be used with a ListBlock. If I am using a screen block, I need to pass my record.

    What is going to trip me up here is that the AddressRecord is not the record that I need to display, I need to display the Contacts associated with that AddressRecord from an external table (I didn't design how these connect..however, that is the connection I have to work with. :-)). The system is designed so that when you are working with the locations, the user is in the context of the Address entity. Therefore, the addr_addressID is what you can pull out of the URL. On the address record in CRM is a field for the location alias. The alias is the unique identifier in the external table for the record I want.

    Therefore, I am getting to the record this way ---> Address ID ---> addr_localias ---> addr_localias = alias ---> alias = myRecord in the External database.

    Since I believe I understand that I need to pass a record not an Arg to the screen block, I need to figure out how I filter that record to the actual record that I want. I am sure that I have seen how to do this before...just don't remember how. If I were writing SQL, I could do it.

    I am off to do more research on FindRecord and I am hoping that is the direction I need to go. If I am headed in the wrong direction, please let me know and shove me in a different one!

    Thank you for your assistance!!!

Children
No Data